nginx如何开启pathinfo-创新互联
这篇文章将为大家详细讲解有关nginx如何开启pathinfo,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

apache往nginx去转,代码端用到了$_SERVER['PATH_INFO'],对于nginx默认是不开启pathinfo的。所以我们就要手动开启
1,url重写
location / { //方法1
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location / { //方法2
try_files $uri $uri/ /index.php$uri;
}2,pathinfo设置
location ~ .*\.(php|php5)(.*)?$ //注意这块,配置重写的url
{
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 PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi.conf;
}这块要注意,location后正则要根据重写的url来决定。
关于“nginx如何开启pathinfo”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
分享名称:nginx如何开启pathinfo-创新互联
路径分享:http://www.jxjierui.cn/article/hhsci.html


咨询
建站咨询
