Location-nginx rewrite index. php/For I/

Source: Internet
Author: User
Tags centos server
The following is the nginx configuration file of my CentOs server. Now you can access index normally. php, but now there is a rewrite requirement, that is, I enter 23. abc. comiabc is rewritten to 23. abc. comindex. phpabc, that is, index. php is replaced by I. Below is the nginx configuration file of my CentOs server. Now I can access index. php normally, but now there is a rewrite requirement, that is, I enter the rewrite. On the basis of the following, how should I modify it?
Server {

    listen       80;    server_name  23.abc.com;    index index.html index.htm index.php;    root  /home/wwwroot/test/;            location ~ \.php($|/) {                    set  $script     $uri;                    set  $path_info  "";                    if ($uri ~ "^(.+\.php)(/.+)") {                            set  $script     $1;                            set  $path_info  $2;                    }                    #fastcgi_pass   127.0.0.1:9000;                    fastcgi_pass unix:/tmp/php-cgi.sock;                    fastcgi_index  index.php;                    include fcgi.conf;                    fastcgi_param  SCRIPT_FILENAME    $document_root$script;                    fastcgi_param  SCRIPT_NAME        $script;                    fastcgi_param  PATH_INFO          $path_info;            }    }

Reply content:

The following is the nginx configuration file of my CentOs server. Now index. php can be accessed normally, but now there is a rewrite requirement, that is, when I input 23.abc.com/ I /abc, rewrite it to 23.abc.com/index.php/abcto replace index.phpwith I. On the basis of the following, how should I modify it?
Server {

    listen       80;    server_name  23.abc.com;    index index.html index.htm index.php;    root  /home/wwwroot/test/;            location ~ \.php($|/) {                    set  $script     $uri;                    set  $path_info  "";                    if ($uri ~ "^(.+\.php)(/.+)") {                            set  $script     $1;                            set  $path_info  $2;                    }                    #fastcgi_pass   127.0.0.1:9000;                    fastcgi_pass unix:/tmp/php-cgi.sock;                    fastcgi_index  index.php;                    include fcgi.conf;                    fastcgi_param  SCRIPT_FILENAME    $document_root$script;                    fastcgi_param  SCRIPT_NAME        $script;                    fastcgi_param  PATH_INFO          $path_info;            }    }

Rewrite 23.abc.com/.#/abc 23.abc.com/index.php/abc break;

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.