Allow Nginx to support thinkphp URL rewriting and PathInfo
Enable the thinkphp to operate correctly on Nginx.
Simply add the following information in the configuration file to allow Nginx to parse the thinkphp website correctly.
?
?
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 $ ; Set $path _info ; } 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; }
Here, the requests under Project are forwarded to index.php for processing, that is, the single entry file for thinkphp, and then the request to the PHP file is given to fastcgi for processing, and the support for Path_info is added.
After restarting Nginx, Http://localhost/project/Index/insert, http://localhost/project/index.php/Index/delete such URLs can be correctly accessed.
One more place to note is that there is a space between the if and the parentheses in the Nginx configuration file, otherwise the unknown directive error will be reported.
?
Author: Playing upon? Posted on 2011-08-08 10:48? Original link
?