0

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?

2 Answers 2

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

4
  • Do not forget to set up proper expire rules for your domain!
    – cstamas
    Sep 29, 2012 at 8:24
  • @chx actually this seems to cause an infinite redirect loop...... Sep 29, 2012 at 8:28
  • @chx I added a line, I hope you don't mind.
    – cstamas
    Sep 29, 2012 at 8:46
  • @cstamas correct. Also "RewriteRule ^(index\.htm){0}$ /index.html [L,R=302]" works Sep 29, 2012 at 8:46
0

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

1
  • 1
    An alternative way to avoid getting the maintenance page indexed is to add it the robots.txt file(s). Sep 29, 2012 at 10:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .