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 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
add comment

2 Answers

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...... –  djechelon 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 –  djechelon Sep 29 '12 at 8:46
    
Thanks for the correction. –  chx Sep 29 '12 at 22:55
add comment

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
1  
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
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.