这应该是一项简单的任务:为特定网址发送404重定向:/ folder1 / folder2
这是我尝试过的:
RewriteEngine on
RewriteBase /
#RewriteRule ^folder1/folder2/(.*)$ /folder1/folder2/$1 [R=301,L] (works, but I want a 404)
RewriteRule ^/?folder1/folder2 - [R=404] (does not work)
RewriteRule ^folder1/folder2 - [R=404,L] (does not work)
RewriteCond %{REQUEST_URI} ^/folder1/folder2
RewriteRule ^ - [L,R=404] (does not work)
RedirectMatch 404 folder1/folder2(.*)$ (does not work)
RewriteRule ^folder1/folder2(.*)$ /not-found.html [L,R=404] (does not work)
# This works, but is not what I need:
RewriteRule ^(.*)$ /not-found.html [L,R=404]
测试规则(http://htaccess.mwl.be/)时,它们按预期工作,但不在我的localhost上。发生了什么事?
我正在运行Apache 2.4。
感谢您的帮助!