Nginx服务器不支持PATH_INFO的问题及解决办法

在ThinkPHP5中  发现URL 不支持典型模式访问  http://serverName/index.php(或者其它应用入口文件)/模块/控制器/操作/[参数名/参数值...]

因为默认nginx不支持PATHINFO 只能通过http://serverName/index.php(或者其它应用入口文件)?s=/模块/控制器/操作/[参数名/参数值...]

感觉好烦哦 于是就想办法修改配置

location ~ .php$ { //$代表结尾,这样对于后面跟随内容的URL地址就不会进行解析
     fastcgi_index index.php;
     fastcgi_pass 127.0.0.1:9000;
     include fastcgi_params;
}

上面的配置Nginx是不会正交给php cgi服务器的. 所以我们需要改写这段配置为:

location ~ .php {
     fastcgi_index index.php;
   fastcgi_split_path_info ^(.+.php)(.*)$; #增加这一句
fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句 fastcgi_pass 127.0.0.1:9000; include fastcgi_params; }
原文地址:https://www.cnblogs.com/phpwyl/p/10482300.html