nginx下Thinkphp 隐藏index.php

时间:2024-02-19 10:28:31

thinkphp config配置:

\'URL_MODEL\'          => \'2\', //URL模式

nginx rewrite配置:

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

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

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