nginx环境,二级目录下怎么去掉首页的forum.php

如题所述

    把index.php设为默认搜索页

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

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;

}

}

   

温馨提示:答案为网友推荐,仅供参考
相似回答