The pattern matches for everything except maintenance.html and sends the request to maintenance.html. That is important, because at first I tried to redirect all requests by matching on ^/(.*) but that got into an endless loop, since it would redirect request to maint page which redirected to the maint page which redirected to, well you get the idea.
Here is my rule:
RewriteEngine On
#RewriteRule !^/maintenance.html$ /maintenance.html [R,L]
Save file, cd ../bin and sudo ./apachectl restart and presto! All requests go to maintenance.html instead of the intended destination. Comment out those 2 lines, restart, and all normal.
Links of interest:
- http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
- http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
FOLLOWUP - 3/29
My maintenance redirect wasn't working for requests already coming in over SSL. I had to add the rule to the secure virtual host config section as well for it to work. Special thanks to "shimmyshack" on the alt.apache.configuration newsgroup for pointing me in the right direction.
3 comments:
You can do all this without having to restart apache, just insert a condition before your rewriterule, like:
RewriteCond /var/www/maintenance.html -f
RewriteRule ^.*$ /var/www.maintenance.html
Hi ,
I have kept my missing.html in htdocs. Now this page contains a logo which is not getting displayed in the maintainenece page. The access logs show a 304 for the image file.
"GET /missing.html HTTP/1.1" 200 3378
147.151.236.104 - - [04/Dec/2012:10:02:26 +0000] "GET /BT_45pix_pos.gif HTTP/1.1" 304 -
Please help
Thanks,
Olive
Thank you for being youu
Post a Comment