Apache覆盖500 HTTP状态码响应

4

我正在使用Apache作为代理服务器。当我的Web应用程序向AJAX调用返回500错误代码时,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服务器更改。
2个回答

0

我遇到了类似的问题,我正在使用以下代码:(PHP)

header("HTTP", true, 500);

替代

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

这段代码在我的本地XAMPP服务器上可以正常工作,但在某些其他服务器上却不能。改用HTTP/1.0响应方式后,两者都可以正常工作。


-1
检查你的 httpd.conf 文件,看看 Apache 存储错误的位置。 然后你可以使用 tail error.log 查看最近的错误信息或者使用 cat error.log 查看所有的错误信息。

如果没有错误,使用 vim offending.file.ext 命令查看代码是否有错误。可能是行尾或语法错误。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接