【问题标题】:Apache overrides 500 HTTP status code responsesApache 覆盖 500 个 HTTP 状态码响应
【发布时间】:2011-12-21 09:41:31
【问题描述】:

我使用 Apache 作为代理服务器。当我的 Web 应用程序发送 500 错误代码作为对 AJAX 调用的响应时,apache 会显示它自己的默认内部错误消息

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 you@example.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>

有没有办法避免这种情况,这样错误响应就不会被 apache 服务器变形。

【问题讨论】:

    标签: apache http status


    【解决方案1】:

    我遇到了类似的问题,我使用的是代码:(PHP)

    header("HTTP", true, 500);
    

    而不是

    header("HTTP/1.0 500 Internal Server Error");
    

    第一个在我的本地 XAMPP 服务器上有效,但在某些其他服务器上无效,切换到 HTTP/1.0 响应在两者上都有效。

    【讨论】:

      【解决方案2】:

      检查您的 httpd.conf 文件以了解 Apache 存储错误的位置。 然后您可以tail error.log 查看最近的错误或cat error.log 查看所有错误。

      如果没有错误,vim offending.file.ext 看看是否有任何错误。可能是行尾或语法错误。

      否则,我建议让我们看看代码。

      【讨论】:

        猜你喜欢
        • 2014-01-08
        • 2018-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-28
        相关资源
        最近更新 更多