/foo/index.html
経由でアクセスしたいファイルがある場合/bar/index.html
は、書き直せば簡単です:
RewriteRule ^bar/(.*)$ foo/$1 [L] # <-- Leaves URL the same, but gives content of foo/
しかし、それはコンテンツにアクセスするために/foo/index.html
と現在の両方が機能することを意味します。/bar/index.html
経由のアクセスを禁止する方法はあります/foo/index.html
か? ただやっている:
RewriteRule ^foo/(.*)$ bar/$1 [R=301,L] # <-- Change the URL if accessed via /foo
RewriteRule ^bar/(.*)$ foo/$1 [L] # <-- Leaves URL the same, but gives content of foo/
リダイレクト ループが発生します。「URL が既に '/bar' でない限り、foo を bar にリダイレクトする」ことを示す方法はありますか?