简体   繁体   中英

Apache overrides 500 HTTP status code responses

I am using Apache as a proxy server. When my web application sends a 500 error code as response to an AJAX call, apache displays it own default internal error message

<!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>

Is there a way to avoid this, so that the error response doesnot get morphed by apache server.

Check your httpd.conf file for where Apache is storing errors. You can then tail error.log to see the most recent errors or cat error.log to see all the errors.

If there are no errors, vim offending.file.ext to see if anything looks incorrect. Might be line endings or syntax errors.

Otherwise, I suggest letting us see the code.

I had a similar issue, I was using the code: (PHP)

header("HTTP", true, 500);

instead of

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

The first worked on my local XAMPP server but not on certain other servers, switching to the HTTP/1.0 response instead worked on both.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM