Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a static "site under maintenance" page. I want that, for a particular vhost, that page is displayed for any URL request. If I just switch the vhost to the directory containing the page, requests to index.html will hit the page, but others will throw 404 error.

So how to display that page for any URL under a certain vhost?

share|improve this question
up vote 2 down vote accepted
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index.html
RewriteRule ^.*$ /index.html [L]

Done! Every request will be rewritten to index.html. You can even do [L,R=302] to create a temporary redirect, to be nicer.

share|improve this answer
Do not forget to set up proper expire rules for your domain! – cstamas Sep 29 '12 at 8:24
@chx actually this seems to cause an infinite redirect loop...... – usr-local-ΕΨΗΕΛΩΝ Sep 29 '12 at 8:28
@chx I added a line, I hope you don't mind. – cstamas Sep 29 '12 at 8:46
@cstamas correct. Also "RewriteRule ^(index\.htm){0}$ /index.html [L,R=302]" works – usr-local-ΕΨΗΕΛΩΝ Sep 29 '12 at 8:46
Thanks for the correction. – chx Sep 29 '12 at 22:55

Thanks to the feedback of the other answer here is an alternate that doesn't get indexed by spiders

RedirectMatch 503 ^/(?!index\.html|yaml|work|css|screen)
ErrorDocument 503 /index.html
Header always set Retry-After "18000"

yaml, work, css and screen are directories referenced by index.html

share|improve this answer
An alternative way to avoid getting the maintenance page indexed is to add it the robots.txt file(s). – John Gardeniers Sep 29 '12 at 10:05

Your Answer


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.