Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to rollout different error pages once their occures an internal server error.

I know you can define your own error pages using apache using that directive

ErrorDocument 500 /errors/500.html

But, I want to show a human readale version on my frontpage, but ship an xml file once my api runs into an internal server error. I tried using RewriteCond, but even though there was no configuration issue I could not get the expected results.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can have your error document be a script in your preferred script language, and have the logic deciding what to show in the script rather than in Apache. If you don't want to do that, you will have to have separate directories where you have different error pages - the ErrorDocument directive can be put inside a <Directory> context.

share|improve this answer
    
mh but what if the server has actually a global problem and not one related to just one request. in that case I should expect my script not work as well so the regular error document gets shiped. I would prefer configuring that directly inside the webserver –  mlaug May 11 '12 at 8:39
    
If the server is having problems running any kind of script whatsoever, then obviously having a script as an error page won't work. But if the problem is that your application doesn't work, that doesn't necessarily mean that the error page would also be affected. To make an example - if your database is down, your application won't work, but a script that doesn't require the database still will. Or you can have your app in a subdir, and have a different error page just for the subdir –  Jenny D May 11 '12 at 14:34
    
I undestand your point. Still I do not think that it is an satisfying solution, I will try it this way –  mlaug May 15 '12 at 11:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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