我正在使用 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 服务器变形。
最佳答案
我遇到了类似的问题,我正在使用代码:(PHP)
header("HTTP", true, 500);
代替
header("HTTP/1.0 500 Internal Server Error");
第一个在我的本地 XAMPP 服务器上工作但在某些其他服务器上不工作,切换到 HTTP/1.0 响应而不是在两个服务器上工作。
关于Apache 覆盖 500 个 HTTP 状态代码响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7999232/