tp5 在nginx上不支持pathinfo,要做以下修改
修改网站的nginx.conf文件
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;
include fastcgi_params;
}隐藏index.php,放在location块内外均可
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}ps:编辑完保存,重启nginx服务

本文详细介绍了如何在Nginx服务器上正确配置ThinkPHP 5 (TP5) 的PathInfo支持,通过修改Nginx配置文件实现隐藏index.php,并确保URL重写规则正常工作。适用于希望改善TP5项目部署流程的开发者。
854





