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

来源:互联网 发布:php防止接口频繁调用 编辑:程序博客网 时间:2024/04/23 16:57
之前没有在意一直都是在Apache下部署,换成Nginx折腾了半天。终于搞定。


[plain] view plain copy
  1. #  
  2. # The default server  
  3. #  
  4.   
  5.     server {  
  6.         listen       80;  
  7.         server_name  **  
  8.         location / {  
  9.             root   /www/;  
  10.             index  index.php index.html index.htm;  
  11.         }  
  12.         error_page   500 502 503 504  /50x.html;  
  13.         location = /50x.html {  
  14.             root   html;  
  15.         }  
  16.         location ~ \.php {                   #去掉后面的$  
  17.             root           html;  
  18.             fastcgi_pass   127.0.0.1:9000;  
  19.             fastcgi_index  index.php;  
  20.              fastcgi_split_path_info ^(.+\.php)(.*)$;                             #增加这一句  
  21.         fastcgi_param PATH_INFO $fastcgi_path_info;                          #还有这一句  
  22.         #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
  23.         fastcgi_param  SCRIPT_FILENAME  /site/www.xxr.so/$fastcgi_script_name;  
  24.         # 这个是在配置nginx+php整合的时候就改好的$前面的是网站的主目录  
  25.             include        fastcgi_params;  
  26.         }          
  27.     }  

最后,不要忘了在 php.ini 中将 cgi.fix_pathinfo=0 改为1
原创粉丝点击