I would like to rewrite requests to directory secret (http://example.com/secret) with .htaccess file to show always 404 Not Found error. I'm using Apache 2.4.
It should work for those cases:
My .htaccess rules block everything except the last two cases (I'm getting 403 error, but it should be 404):
Options -Indexes
RewriteEngine On
RewriteRule ^secret.*$ - [R=404,L]
I would like to rewrite requests /secret/.php and /secret/.htaccess to "404 Not Found error".
UPDATE: This is a bit hacky but seems to block everything
Options -Indexes
RewriteEngine On
RewriteRule ^secret.*$ - [R=404,L]
RewriteRule ^404_error$ - [R=404,L]
<FilesMatch "^\.">
order allow,deny
# 403 error
deny from all
# Rewrite 403 error to 404 error
# Must be an absolute path
ErrorDocument 403 /404_error
</FilesMatch>