Rewrite rule for "site down" pages

Paul Tarjan picture Paul Tarjan · Aug 27, 2009 · Viewed 10k times · Source

I was trying to install this .htaccess to notify my users of site maintenance. It seems the first [L] isn't working and the second rewrite is doing everything.

How do you guys do site maintenance messages?

RewriteEngine on

RewriteRule ^s/down$ index.html [L]
RewriteRule ^(.*)$ http://metaward.com/s/down [R=302,L]

Answer

Gumbo picture Gumbo · Aug 27, 2009

You don’t need to an external redirect. Just send the 503 status code and your error document.

RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteRule ^(.*)$ /503.html [R=503,L]
ErrorDocument 503 /503.html

But you need Apache 2.x to use a different status code with the R flag other than 3xx.