Reputation: 776
I am trying to set up a maintenance mode using .htaccess
, which allows a user visiting from a certain IP to still view the site. The site is running from a CMS (Perch Runway) which uses rewrite rules as part of the system, so these would need to be working for the visitor from that IP. The Perch Runway code is this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/perch
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /admin/core/runway/start.php [L]
My redirect maintenance code is this:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]
I have tried combining the two but am getting a redirect loop. So in short I need to have:
Please note I want to show the maintenance.html
page to those not visiting from the specified IP, so can't use deny
.
Help greatly appreciated!
Upvotes: 0
Views: 757
Reputation:
In combination with answer which was posted in comment, I tested this on a Wordpress page and it works:
ErrorDocument 403 /liesmich.html
order deny,allow
deny from all
allow from 111.222.333.444
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
So for Perch Runway would look something like this I bet:
ErrorDocument 403 /maintenance.html
order deny,allow
deny from all
allow from 111.222.333.444
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/perch
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /admin/core/runway/start.php [L]
Posting an answer from comments because new lines are being cut off and code looks terrible.
Upvotes: 0