问题
This is sort of a follow-up to Is there a way to force apache to return 404 instead of 403? which suggested RedirectMatch to 404 to accomplish this.
It works perfectly fine for most of anything, however if I request:
http://example.com/.htaccess
I get a 403 and not a 404 if I have (or not) this in my .htaccess file:
RedirectMatch 404 ^/\.htaccess$
Is there a way to override the default 403 - Forbidden behavior of apache from inside the .htaccess file itself?
回答1:
Just after I posted my question, I came to a solution towards the following:
- Mimic the default server configuration's
<Files>rules for.httype of files. - Allow them.
- Redirect them to 404.
Works like this:
<Files ~ "^\.ht">
Order Deny,Allow
Allow from all
Satisfy All
Redirect 404 /
</Files>
来源:https://stackoverflow.com/questions/7945795/requests-to-htaccess-should-return-404-instead-of-403