2

I have a development server and I would like to configure Apache so that when a 500 http code is generated it will display the error directly in the response (i.e. what would be printed to /var/log/httpd/error_log is displayed to the user).

However, I cannot figure out where this directive is.

Any help?

3

I believe the directive you are looking for is ErrorDocument (documented here). For example:

<VirtualHost *:80>
    ...

    ErrorDocument 500 /error/500.html
</VirtualHost>

On a second read-through of your question it appears you may be asking for Apache to display the error directly in the browser (i.e. what would appear in /var/log/httpd/error_log). Can you clarify?

| improve this answer | |
  • Hi. Your second guess is the one I am interested in. I want it to print the error to the browser, not a custom error page. Thanks – Thomas Feb 21 '12 at 14:44
  • 3
    This isn't seemingly easy as it represents a complex change in how Apache normally handles these errors. I can appreciate how frustrating it can be to not get immediate assistance from volunteers during their work day... – Kyle Smith Feb 21 '12 at 16:04
  • 1
    @Thomas As far as I'm aware there's no way to do this without putting it together yourself with dynamic code in a custom 500 handler page. I can't blame Apache for not building it in, either - having this on a production web server would be reckless information disclosure, while using it for debugging seems pointless since the error log is easily tail-able. – Shane Madden Feb 21 '12 at 16:28
2

Set up Apache to use server-side includes (.shtml files) and configure a custom error page as above (though naturally pointing to an .shtml file), and in that custom error page use something like this:

<p>The requested page, <code>
<!--#echo var="REQUEST_URI" --></code>,
 does not work properly.</p>

<p>Click <a href='<!--#echo var="HTTP_REFERER" -->'>here</a> to return from whence you came.</p>

<fieldset>
<legend>Error Message</legend>
<xmp>
<!--#echo var="REDIRECT_ERROR_NOTES" -->
</xmp>
</fieldset>

<!--
<!--#echo var="HTTP_USER_AGENT" -->
<!--#echo var="REDIRECT_STATUS" -->
-->
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.