Reputation: 87
I need to carry out maintenance on the site and be the only one who can access it. I wrote the following rewrite rule:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^46\.233\.116\.53
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://maydomain.com/maintenance.html [R=307,L]
I should redirect any IP to the maintenance page except mine (46.233.116.53) but unfortunately is redirecting mine too. I also tried to wrap the rule within
<IfModule mod_rewrite.c>
.....
</IfModule>
But still no luck. Is there anything my hosting should do as they seem to have no suggestion :(
Upvotes: 0
Views: 584
Reputation: 744
This is what I currently use.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^00\.000\.00\.00 #Replace with real ip
RewriteCond %{REQUEST_URI} !/maintenance.htmlp$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
Upvotes: 1