项目二级目录下的index.php使用nginx重写

来源:互联网 发布:网络摄像头有看头下载 编辑:程序博客网 时间:2024/05/01 10:16
我想重写一个www.xxx.com/shuicao/index.php/aaa/bbb.html为www.xxx.com/shuicao/aaa/bbb.html、也就是把网站项目的二级目录(shuicao)的index.php隐藏,我写了这样的重写规则,但是使用www.xxx.com/shuicao/aaa/bbb.html访问的时候,总是会给我定向到www.xxx.com/shuicao/项目下的默认首页(即使我换成www.xxx.com/shuicao/任意字符串,也会定向到首页)。

不知道是不是我的rewrite写错了,还是thinkphp项目的配置问题(我已经配置为URL_MODEL为2,也就是重写模式了)



        location / {
            index  index.html index.htm index.php l.php;
            autoindex  off;
            
            if (!-e $request_filename)
            {
                    #地址作为将参数rewrite到index.php上。
                    rewrite  ^/(.*)$ /index.php/$1 last;
            }
        }
        
        location /shuicao/ {
            index  index.html index.htm index.php l.php;
            autoindex  off;
            
            if (!-e $request_filename){
                rewrite  ^/shuicao/(.*)$  /shuicao/index.php/$2  last;
            }
        }






0 0
原创粉丝点击