时时商务社区
标题:
thinkphp在低版本Nginx 下支持PATHINFO的方法分享
[打印本页]
作者:
新格网络
时间:
2018-2-14 05:35
最近在用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。)
您可能感兴趣的文章:
让Nginx支持ThinkPHP的URL重写和PATHINFO的方法分享
在nginx中配置pathinfo模式支持thinkphp的URL重写
Nginx隐藏index.php和Pathinfo模式配置例子
nginx支持codeigniter的pathinfo模式url重写配置写法示例
nginx中配置pathinfo模式示例
lnmp环境中如何为nginx开启pathinfo
nginx+thinkphp下解决不支持pathinfo模式
Ubuntu下Nginx配置ThinkPHP的Pathinfo和URl Rewrite模式
Nginx配置PATHINFO隐藏thinkphp index.php
Nginx下配置pathinfo及ThinkPHP的URL Rewrite模式支持
解决nginx不支持thinkphp中pathinfo的问题
nginx配置支持php的pathinfo模式配置方法
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2