nginx下重写隐藏index.php文件

location / {


        root   /项目目录/;
        index  index.php;

        if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
                rewrite (.*) /index.php;
        }

       #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则 thinkphp 部署到linux 下常用
          if (!-e $request_filename)
              {
                    #地址作为将参数rewrite到index.php上。
                    rewrite ^/(.*)$ /index.php/$1;
                    #若是子目录则使用下面这句,将subdir改成目录名称即可。
                    #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
              }



}

猜你喜欢

转载自www.cnblogs.com/phper12580/p/10510042.html