您好,欢迎访问一九零五行业门户网

thinkphp在低版本Nginx 下支持PATHINFO的方法分享,nginxpathinfo_PHP教程

thinkphp在低版本nginx 下支持pathinfo的方法分享,nginxpathinfo最近在用thinkphp做一个项目,基本完成后部署到nginx服务器上才发觉nginx是不支持pathinfo的那么我们如何来处理呢。
nginx环境
在nginx低版本中,是不支持pathinfo的,但是可以通过在nginx.conf(在/usr/local/nginx/conf/nginx.conf或者通过find / | grep nginx.conf来查找位置)中配置转发规则实现:在nginx配置文件中添加:
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; }}
其实内部是转发到了thinkphp提供的兼容模式的url,利用这种方式,可以解决其他不支持pathinfo的web服务器环境。
如果你的thinkphp安装在二级目录,nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。
location /youdomain/ { if (!-e $request_filename){ rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last; }}
如:
location /thinkphp/ { if (!-e $request_filename){ rewrite ^/thinkphp/(.*)$ /thinkphp/index.php?s=$1 last; }}
语法:rewrite regex replacement flag  (last     相当于apache里面的[l]标记,表示rewrite。)
http://www.bkjia.com/phpjc/1133067.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1133067.htmltecharticlethinkphp在低版本nginx 下支持pathinfo的方法分享,nginxpathinfo 最近在用thinkphp做一个项目,基本完成后部署到nginx服务器上才发觉nginx是不支持...
其它类似信息

推荐信息