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;