nginx 下部署thinkphp5 遇到的pathinfo问题

thinkphp5 官方已默认用 pathinfo 模式,但nginx是没有这个的,pathinfo是属于PHP的东西。

但nginx 可以读取这个扩展。

1、在nginx的目录下,找到这行,把正则匹配的结束符$符号去掉

location ~ \.php(.*)$  {

加上

fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_param  PATH_INFO  $fastcgi_path_info;
fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
include        fastcgi_params;

2,再找到php.ini

把这个扩展打开,cgi.fix_pathinfo=1(可以不开打,鸟哥文章中说有漏洞)


另外

如果,想要隐藏index.php文件的话,则在location /{ 里加

if (!-e $request_filename) {
      #若是子目录则使用下面这句,将subdir改成目录名称即可。
      rewrite ^/task/(.*)$ /task/index.php/$1;
      rewrite ^/test/task/(.*)$ /test/task/index.php/$1;
}




猜你喜欢

转载自blog.csdn.net/u011383596/article/details/79848542