1
所以,如果我有這樣的當前設置。重寫除一些選擇路徑之外的所有子目錄
domain.com/some-path/
domain.com/some-path/locations/
domain.com/some-path/locations/some-location
domain.com/some-path/locations/locb
domain.com/some-path/locations/infinite-location-list
這些是我不想重寫的URL模式。 some-path
子目錄,它的子目錄locations
子目錄,以及任何在locations
之下的目錄。
some-path
目錄下的所有其他子URL應該301指向/some-path/
目錄。
我想是這樣的:
location ~* ^/some-path/(.+)? {
if ($request_uri !~ "^/some-path/locations/(.*)$") {
return 301 http://domain.com/some-path/;
}
}
但/some-path/
卡在重定向循環,和/some-path/locations/
拋出一個服務器端的nginx如何實現我的目標404
的思考?
完全同意你的設計方面。我實際上正在推動這一要求。該網站的該部分/子目錄需要大量的重寫/重定向,這些重寫或重定向對於單獨編寫而言是完全無效的。如果我失敗了,這將成爲我的備用解決方案。 – Nathan
@Nathan,好吧,瘋狂重寫沒什麼問題 - 結帳http://mdoc.su/,它也是我的github上的開源代碼,只要用戶體驗上升,而不是下降。 :-) – cnst