对于我的网页,我有一个.htaccess
文档看起来像这样
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 404 /websites/404/index.php
现在据我了解,您可以进一步包括ErrorDocument
只需添加另一行即可。例如
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 404 /websites/404/index.php
ErrorDocument 503 /websites/maintenance/index.php
但是,当我尝试添加页面时HTTP 451 https://en.wikipedia.org/wiki/HTTP_451使用以下代码行ErrorDocument 451 /websites/451/index.php
然后我重新加载我的页面,我得到一个Server error! Error 500
。后来我发现这是因为XAMPP https://www.apachefriends.org/index.html不再用.htaccess
文件中,错误只能通过删除来解决ErrorDocument
for error 451
。造成这种情况的原因是什么以及如何解决它?
Note
我还发现这种情况发生在error 418: I'm a teapot
as well
EditJust to include a little more information about the software I am using. I am using
- XAMPP 控制面板 v3.2.2
- Apache 2.4.17 - 这是 XAMPP 附带的版本
尽管有很多 HTTP 状态代码(由 IANA 正式维护 http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml),并非所有网络服务器都支持所有这些。从 Apache 2.4 开始,状态代码 418 和 451 不受支持,Apache 会默默地转换为错误 500。
Apache 2.4 中最新添加的受支持状态代码是 414 和 501,以及 400 的崩溃预防(来自Apache 2.4 变更日志 http://www.apache.org/dist/httpd/CHANGES_2.4):
core:支持 HTTP 501 和 414 状态代码的自定义 ErrorDocuments。
PR 57167 [卢爱德华]
核心:防止服务器因无效 CONNECT 请求而崩溃
使用服务器端包含的状态代码 400 的自定义错误页面。
PR 58929 [鲁迪格·普卢姆]
See the 支持的 HTTP 状态代码列表 http://www.askapache.com/net/http-status-codes.html(从 Apache 2.4.4 开始)。
请参阅关于 2.2 的旧错误(针对 2.2 提交)将自定义状态代码重新映射为 500 错误 https://bz.apache.org/bugzilla/show_bug.cgi?id=44995.
看到这个上一个关于类似问题的问题 https://stackoverflow.com/questions/17735514/php-apache-silently-converting-http-429-and-others-to-500(也适用于 Apache 2.2)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)