JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

配置Nginx服务器支持path_info

wys521 2024-09-18 02:48:27 精选教程 23 ℃ 0 评论

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

因为默认nginx不支持PATHINFO 只能通过http://xxx.com/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;
}

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表