加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx 开启 pathinfo

发布时间:2020-12-13 21:41:35 所属栏目:Nginx 来源:网络整理
导读:apache往nginx去转,代码端用到了$_SERVER['PATH_INFO'],对于nginx默认是不开启pathinfo的。所以我们就要手动开启 1,url重写 location / { //方法1 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; }}location / { //方法2 try_

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来决定。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读