專案二級目錄下的index.php使用nginx重寫
阿新 • • 發佈:2019-01-24
我想重寫一個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,也就是重寫模式了)
不知道是不是我的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;
}
}