对 .htaccess 的请求应该返回 404 而不是 403 [英] Requests to .htaccess should return 404 instead of 403
本文介绍了对 .htaccess 的请求应该返回 404 而不是 403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是有没有办法强制 apache 返回 404 而不是 403? 建议 RedirectMatch
到 404 来完成这个.
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
如果我的 .htaccess
文件中有(或没有),我得到的是 403 而不是 404:
I get a 403 and not a 404 if I have (or not) this in my .htaccess
file:
RedirectMatch 404 ^/\.htaccess$
有没有办法从 .htaccess
文件本身覆盖默认的 403 - apache 禁止行为?
Is there a way to override the default 403 - Forbidden behavior of apache from inside the .htaccess
file itself?
推荐答案
就在我发布我的问题之后,我找到了以下解决方案:
Just after I posted my question, I came to a solution towards the following:
- 为
.ht
类型的文件模仿默认服务器配置的
规则. - 允许他们.
- 将它们重定向到 404.
- Mimic the default server configuration's
<Files>
rules for.ht
type of files. - Allow them.
- Redirect them to 404.
工作方式如下:
<Files ~ "^\.ht">
Order Deny,Allow
Allow from all
Satisfy All
Redirect 404 /
</Files>
这篇关于对 .htaccess 的请求应该返回 404 而不是 403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文