如题, nginx服务器是不支持path_info.需要配置nginx文件.
博主本地环境是window + 2018 phpstudy
进入phpstudy安装目录, 进入nginx文件夹, 再进入conf文件,打开vhosts.conf文件增加如下语句(重写ur规则):
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=/$1 last;
break;
}
}
然后重启.
最后附上增加完后的vhosts.conf源码如下以供参考(如下 例子根目录是D:\phpstudy2018\PHPTutorial\WWW\option, tp的index.php入口就在option目录下, 建议你配置这个路径也是配置到index.php文件的上级目录即可, 同时注意末尾不要加 \ 不然会导致phpstudy无法重启.
server {
listen 80;
server_name www.option.com ;
root "D:\phpstudy2018\PHPTutorial\WWW\option";
index index.html index.htm index.php;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.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;
}
}
原文链接:https://blog.youkuaiyun.com/weixin_37281289/article/details/86671527