您的位置:首页 > 运维架构 > Nginx

Nginx部署Thinkphp 404错误PathInfo的解决方案

2016-05-10 17:30 691 查看
之前没有在意一直都是在Apache下部署,换成Nginx折腾了半天。终于搞定。
#
# The default server
#

server {
listen       80;
server_name  **
location / {
root   /www/;
index  index.php index.html index.htm;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
}
location ~ \.php {                   #去掉后面的$
root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;                             #增加这一句
fastcgi_param PATH_INFO $fastcgi_path_info;                          #还有这一句
#fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
fastcgi_param  SCRIPT_FILENAME  /site/www.xxr.so/$fastcgi_script_name;
# 这个是在配置nginx+php整合的时候就改好的$前面的是网站的主目录
include        fastcgi_params;
}
}
最后,不要忘了在 php.ini 中将 cgi.fix_pathinfo=0 改为1nginx 1.6.2 和上面的稍有不同。
server {
listen       80;
server_name  meiman.com ;
root   "E:/www/ymems";
location / {
index  index.html index.htm index.php;
#autoindex  on;
	 ##增加下面的内容if (!-e $request_filename) {rewrite ^/(.*)$ /index.php/$1 last;}}location ~ \.php(.*)$ {fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_split_path_info ^(.+\.php)(.*)$;fastcgi_param   PATH_INFO $fastcgi_path_info;fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;include        fastcgi_params;}}
今天换了个环境,发现用上面的方法不管用。在网上找了试试这个管用。另外也许有的不在根目录,参考下面的。
location / {if (!-e $request_filename) {###一级目录下rewrite ^/(.*)$ /index.php/$1 last;###域名下的二级目录#rewrite ^/目录名/(.*)$ /目录名/index.php/$1 last;}}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: