我正在嘗試執行以下操作:有一個網站,您可以在其中找到格式為http://localhost/username. 我試圖制定一個規則,如果服務器上沒有檔案,那么它將重定向到index.php?username=username. 但問題是它重定向了所有東西,甚至是 js 和 css。我想這樣做,如果檔案在服務器上,那么它會訪問它,如果不是,那么它會發出請求
index.php?username=username
有這段代碼:
rewrite ^/(. )$ /index.php?type=userinfo&username=$1 last;
uj5u.com熱心網友回復:
用于try_files確定檔案是否已經存在,如果不存在,則分支到包含重寫規則的命名位置。
例如:
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(. )$ /index.php?type=userinfo&username=$1 last;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/441015.html
上一篇:修改laravel中的默認登錄
