我需要將這兩個Urls重定向到一個自定義404頁面。 https://example.com/frontend/#/。 https://example.com/frontend/
下面的Nginx配置可以正常作業:
server{
listen 80;
server_name example.com;
error_page 404 /404.html。
location = /404.html {
root /opt/app/nginx/html;
內部。
}
location = /frontend/ {
回傳404。
}
}
然而,這種設定使得具有相同前綴的URL也變成了404,這是個很麻煩的事情 https://example.com/frontend/#/abc。 https://example.com/frontend/#/123。 都重定向到404。 我對404的設定使用了精確匹配(=修改器)。 為什么它仍然影響其他人,我怎樣才能解決它? 謝謝你的幫助! :D
編輯https://example.com/frontend/#/abc。 https://example.com/frontend/#/123都被視為https://example.com/frontend/。 在這種情況下,如果我想把https://example.com/frontend/#/設定為404頁面,我需要做的是在專案中的/frontend檔案夾下創建一個索引頁,并把404內容放在索引頁中,Nginx對重定向包含哈希符號的URL無能為力。
uj5u.com熱心網友回復:
你不能這樣做,因為哈希部分并沒有發送到服務器上。它只用于客戶端的處理。
uj5u.com熱心網友回復:
嘗試使用兩個location
。嘗試使用兩個位置,每個位置中沒有"/"。
location = /frontend {
回傳404; }
location = /frontend/# {
回傳404; }
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/319539.html
標籤:
上一篇:為什么Php過濾器會失敗?
