2

For my personal website, I wanted to make a webpage for every error that could come up on an Apache web server - so that it could fit in better with the style of the website instead of the generic Apache messages. As far as I know, the only way to do that would be to create individual webpages for all 50-some error codes, and individual ErrorDocument entries for each one of those. Is there a way to handle them dynamically (I.e. redirect all errors to a webpage with the error code as a GET/POST value)?

  • 1
    PatomaS touched on this in his answer, but there are considerably less that "50-some" error codes that can be trapped with the ErrorDocument directive and probably only a handful (if that) that will actually occur. – MrWhite Mar 27 '14 at 13:10
3

The best way is to create one ErrorDocument per page, but redirect all errors to the same page. This gives you the dynamic part that you want while you still can change easily that configuration at any time reassigning a new ErrorDocument for specific cases.

Then on that page, you can configure different processes or responses, depending on the REDIRECT_STATUS header.

For the specific situation of the 500 errors, consider that those are server errors, so even when you have an ErrorDocument configured for that situation, it may not be possible to use it, so in some cases just the default message will be presented to the user.

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.