redirect all requests to a specific maintenance-page

New to mod_rewrite? This is a good place to start.

redirect all requests to a specific maintenance-page

Postby urmel1960 » Wed Sep 02, 2009 4:33 am

Hello,

I try to establish a kind of maintenance-mode for my domain. That means that I would like to redirect all requests to a maintenance-page telling the user that the site is temporarily down for maintenance. Only requests to a specific directory should not be redirected (this is the path where the cms-backend is called - otherwise no access even for me to the content and to previews :-))

Code: Select all
Example:

http://xxx.domain.tld/something.html -> redirect to http://xxx.domain.tld/maintenance.html
http://xxx.domain.tld/something_else.html -> redirect to http://xxx.domain.tld/maintenance.html
.
but:
http://xxx.domain.tld/specific_dir/somebackend.html -> no redirect


Can you please help me finding the right way to do this ? Thanks
urmel1960
 
Posts: 3
Joined: Wed Aug 26, 2009 12:05 am

Postby richardk » Wed Sep 02, 2009 9:36 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule !^(maintenance\.html|specific_dir(/.*)?)$ /maintenance.html [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

cron