A recent project used thinkphp as a development framework, the URL we use the pathinfo mode, but nginx default is not supported PathInfo, need to be manually configured to do, We then followed the Nginx pathinfo support configuration According to the following methods:
Modify the nginx.conf, locate the location ~ php${} in the server, modify to location ~. php {}, and add the following:
Copy Code code as follows:
Set $path _info "";
Set $real _script_name $fastcgi _script_name;
if ($fastcgi _script_name ~ "^" ^ (. +?). PHP) (/.+) $ ") {
Set $real _script_name $;
Set $path _info $;
}
Fastcgi_param script_filename $document _root$real_script_name;
Fastcgi_param script_name $real _script_name;
Fastcgi_param path_info $path _info;
However, no matter how we test, we found that the PathInfo mode always does not run correctly, even after running, {: U} method is always error, print $_server found php_self is always wrong.
But still pathinfo can not work correctly, so we determine is thinkphp configuration problem, found that is actually thinkphp _php_file problem, in the entry file index.php add configuration define (' _php_file_ ', $_ server[' Script_name ']), problem solved.
If the $_server[' script_name ' path is also incorrect, replace it with the correct file path first.