[英]ErrorDocument in httpd.conf not working
我想为403使用自定义错误文件,但是apache似乎忽略了指令ErrorDocument
,只是给了我默认错误文件。 这是我的httpd.conf
的开始
ServerRoot "C:/xampp/apache"
Listen 80
ErrorDocument 403 "/403.html"
ErrorDocument 404 "/403.html"
我只是添加了404
以查看它是否有效,但没有成功。 403.html
文件存在于C:\\xampp\\apache\\403.html
我尝试将ErrorDocument
指令在配置文件中进一步下移,其中描述ErrorDocument
指令的注释开始,但结果相同。
我正在测试的文件夹中的任何.htaccess
文件中都没有ErrorDocument
指令。
你能告诉我为什么Apache不理我吗?
只是为了确保我会提及我对此进行测试的方式。 我在C:\\xampp\\htdocs
有一个.htaccess
文件,其内容如下
Order deny,allow
Allow from 127.0.0.1
Allow from ::1
Deny from all
其目的是拒绝访问所有未明确允许的子文件夹和文件,然后我只是向公共IP发送请求以拒绝访问。
如果发生任何错误,首先要查找的是apache安装的logs/error.log
和logs/access.log
日志文件。
正如http://httpd.apache.org/docs/2.2/mod/core.html#errordocument上的文档所述,该指令是相对于当前主机配置的DocumentRoot
的。 您没有使用默认的Apache HTTPD,而是使用了预配置的Apachefriends XAMPP,它具有一些特殊性,例如XAMPP随附的标准httpd.conf
通过以下方式引用ErrorDocument
# Multi-language error messages
Include conf/extra/httpd-multilang-errordoc.conf
在默认的httpd.conf
您的DocumentRoot
是C:\\apache\\htdocs
因此,通过在httpd.conf
上述更改(即ErrorDocument 403 "/403.html"
),您必须将这些文件放入C:\\xampp\\htdocs\\403.html
。
顺便说一句,通常最好将您的自定义配置分开,方法是在httpd.conf
添加一个Include conf/my-custom.conf
并在其中添加您的配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.