【发布时间】:2013-02-04 11:35:07
【问题描述】:
出于安全原因,我让所有 php 文件生成 404 错误,然后使用自定义的 404 错误页面,如下所示:
RewriteCond %{THE_REQUEST} \.php[\ /?].*HTTP/
RewriteRule ^.*$ - [R=404,L]
ErrorDocument 404 /error.html
如我所愿,我访问的任何 php 脚本都会返回一个自定义 404 错误页面,但在其下方显示:
此外,在尝试使用 ErrorDocument 处理请求时遇到 500 Internal Server Error 错误。
但是当我转到一个实际上不存在的页面时(比如说http://localhost/Hello/world.html),我得到了我想要的错误页面。
我很困惑,我做错了什么。另外,我希望能够为我的自定义ErrorDocument 使用 php 页面,但我不确定这是否可能。
【问题讨论】:
-
检查服务器的错误日志以获取有关 500 的详细信息。
-
它只是说超出了内部重定向的限制,但我不知道这是什么意思
标签: .htaccess http-status-code-404 errordocument custom-error-handling