简单配置nginx使之支持pathinfo

ThinkPHP5项目在在本地开发完准备上线,如果服务器和我一样使用的是nginx,并且URL模式选用的是pathinfo模式,那你就有可能遇到和我一样的情况,网站首页访问正常,其他页面出现

404 Not Found 
nginx/1.10.2

nginx默认没有开启pathinfo的支持,只需要修改3个地方就可以了,亲测成功,看代码有注解

location ~ \.php {    #去掉$
     root          H:/PHPServer/WWW;
     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;
     include        fastcgi_params;
}
Last modification:March 14th, 2019 at 01:30 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment