Reputation: 962
So I use the following for to force my site into maintenance mode while updating certain things:
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^23\.1\.12\.167
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
This has worked well, but now I have the situation when in maintenance mode that I wish to exclude certain dir's from being sent to the maintenance.html and rather have them display their normal contents.
So it would be something like:
root/
.htaccess
maintenance.html
index.html
everything.else.html
/do_not_display_me
/display_me_always
Not sure if this is possible from the root level .htaccess or if I'm going to have to get crafty with sub-dir .htaccess files, any help is appreciated.
Upvotes: 2
Views: 4333
Reputation: 165288
This should do the job. It tells Apache to not to rewrite those folders (which makes maintenance rules to be omitted as rewrite chain will never reach them).
# activate rewrite engine
RewriteEngine on
# always allow these folders
RewriteCond %{REQUEST_URI} ^/display_me_always [OR]
RewriteCond %{REQUEST_URI} ^/another_folder [OR]
RewriteCond %{REQUEST_URI} ^/even_more_folders
RewriteRule .+ - [L]
# maintenance rules
RewriteCond %{REMOTE_ADDR} !^23\.1\.12\.167
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
NC,
into [OR]
./
at the end of folder names if you have files in root folder with the same names.Upvotes: 3