nginx+thinkphp下解决不支持pathinfo模式

这种方式是不需要将URL_Model改为rewrite/兼容的

nginx配置代码1

location / { root *; #//这是你自己项目的根目录。 index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 break;
break; } }

在php的配置中,将location ~ .php$ 改为 location ~ .php,再次强调,注意细节,掉了$符号

代码2

location ~ .php { root *; fastcgipass 127.0.0.1:9000; fastcgiindex index.php; fastcgiparam SCRIPTFILENAME $root$fastcgiscriptname; include fastcgiparams; set $pathinfo ""; set $realscriptname $fastcgiscriptname; if ($fastcgiscriptname ~ "^(.+?.php)(/.+)$") { set $realscriptname $1; set $pathinfo $2; } fastcgiparam SCRIPTFILENAME $documentroot$realscriptname; fastcgiparam SCRIPTNAME $realscriptname; fastcgiparam PATHINFO $path_info; }

如果仍未解决,在ThinkPHP入口文件index.php中加入配置define(‘PHPFILE',$SERVER['SCRIPT_NAME']);

axiaoyue

继续阅读此作者的更多文章