[英]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.