[英]apache: redirecting to 403 instead of 404 for hidden directories
實現此目的的最佳方法是更改生成 403 的應用程序。
如果您不能或不願意更改代碼,您可以使用 .htacces 進行內部重定向到一個不存在的位置。 下一行會將所有對存檔目錄的請求重定向到一個不存在的位置。
RewriteRule ^archive(/.*)?$ /this-path-does-not-exist [L]
您還必須為重定向添加一個 RewriteCondition 到您的前面 controller 以防止它被重定向到您的應用程序。
RewriteCond %{REQUEST_URI} !^/this-path-does-not-exist
# ... Other rewrite conditions
# The redirect to your front controller
我已經嘗試了足夠多的東西,比如 RewriteCond %{REQUEST_URI} !^/this-path-does-not-exist
但這對我不起作用......后來,我嘗試了下面的代碼並且對我有用。
Redirect 404 /Directory_Name
謝謝您的幫助!!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.