Rewrite problems in Nginx configuration

Source: Internet
Author: User
I want to implement user requests x.com/api/dosomethingForward to the root directory of the Web site /api.phpProcessing.
Files that do not exist are given to /index.phpProcessing, nginx configuration is as follows

 if (!-e $request_filename) {         rewrite (.*) /index.php$1 last;     }location ^~ /api/{    rewrite (.*) /api.php$1 last;}location ~ (index|api|admin).php {         fastcgi_split_path_info ^(.+\.php)(/.+)$;         fastcgi_pass 127.0.0.1:9000;         fastcgi_index index.php;         include fastcgi_params;         fastcgi_param PATH_INFO $fastcgi_path_info;         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;     }

But I found that when the visit was matched, the order of the alignment was x.com/api/dosomething ! -e $request_filename not used, how should I configure

Reply content:

I want to implement x.com/api/dosomething the processing that the user request forwards to the Web site root directory /api.php .
Non-existent files are given /index.php to the processing, nginx configuration is as follows

 if (!-e $request_filename) {         rewrite (.*) /index.php$1 last;     }location ^~ /api/{    rewrite (.*) /api.php$1 last;}location ~ (index|api|admin).php {         fastcgi_split_path_info ^(.+\.php)(/.+)$;         fastcgi_pass 127.0.0.1:9000;         fastcgi_index index.php;         include fastcgi_params;         fastcgi_param PATH_INFO $fastcgi_path_info;         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;     }

But I found that when the visit was matched, the order of the alignment was x.com/api/dosomething ! -e $request_filename not used, how should I configure

I look at the configuration right ah, I try to say in the local ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.