Let Nginx support ThinkPHP URL rewriting and PATHINFO implementation so that ThinkPHP runs correctly on nginx. You only need to add the following information to the configuration file so that nginx can correctly parse ThinkPHP websites .?? Locationproject {indexindex. php; if (! -E $ reques: enable Nginx to support ThinkPHP URL rewriting and PATHINFO
To make ThinkPHP run correctly on nginx.
You only need to add the following information to the configuration file so that nginx can correctly parse ThinkPHP websites.
?
?
location /project/ { index index.php; if (!-e $request_filename) { rewrite ^/project/(.*)$ /project/index.php/$1 last; break; } } 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; include fastcgi.conf; fastcgi_index index.php?IF_REWRITE=1; fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root/$script; fastcgi_param SCRIPT_NAME $script; }
In this example, all requests under the project are forwarded to the index. php to process, that is, the single portal file of ThinkPHP. then, the request for the php file is sent to fastcgi for processing, and the support for PATH_INFO is added.
After Nginx is restarted, URLs such as http: // localhost/project/Index/insert, http: // localhost/project/index. php/Index/delete can be accessed correctly.
Note that there must be a space between the if and the parentheses in the Nginx configuration file. Otherwise, the unknown ctictive error will be reported.
?
Author :? Or? Posted on? Original article link
?