Skip to content
Advertisement

Apache redirect any 503 error to a maintenance page

I have two vhosts in one server thats using apache – my main page is www.alleOne.com and the other is www.sch2.com. I have a custom page that if www.sch2.com or any other uri page in www.sch2.com/madeup is down a 503 error code, it should redirect to my custom page http://www.alleOne.com/corp/en/service-unavailable.html. This page has a timer and will redirect in 5 seconds to www.alleOne.com ( This part works already). I am trying to see if what I wrote below is correct? Also in the rewrites-enabled were would I add my rules under what vhost www.alleOne.com or www.sch2.com?

RewriteCond %{ENV:REDIRECT_STATUS} !=503 RewriteRule !^www.sch2.com$ http://www.alleOne.com/corp/en/service-unavailable.html [L,R=503]

Advertisement

Answer

You can’t do this with mod_rewrite. Rewrite rules are used to modify requests, you want to modify the response (redirect based on the status). You can use ErrorDocument directive for your purpose.

In www.sch2.com configuration, use

ErrorDocument 503 http://www.alleOne.com/corp/en/service-unavailable.html

More information: ErrorDocument Directive

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement