您的位置:首页 > 运维架构 > Nginx

让nginx支持thinkmcf或thinkphp rewrite模式

2015-08-22 23:40 676 查看
如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中subdir是所在的目录名称。

location /subdir/ {
index index.php
if (!-e $request_filename){
rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1 last;
}
}


如果你的thinkcmf安装在二级目录,Nginx的伪静态方法设置如下,其中subdir是所在的目录名称。

location ~ /subdir/\w+ {
index index.php
if (!-e $request_filename)
{
rewrite ^/(\w+)/(.*)$ /$1/index.php/$2;
}
}


ps: 在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:在nginx配置文件中添加

location / {
index index.php
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: