Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess Maintenance Multiple IP's

Tags:

.htaccess

I am using the code below within my .htaccess file to place my site into maintenance. Essentially what it does is to redirect anyone who is NOT from a specific IP address to a .maintenance. subdomain where I have a maintenance page up (thus allowing me to perform testing on the real site). My question is, how would I add a second IP address to the line:

RewriteCond %{REMOTE_ADDR} !^23\.254\.12\.43

to allow 2 IP's to come through? Is it as simple as just putting a space and using the same format as the first one? (Sorry in advance if it really IS that simple, but I haven't tested it due to fear it may appear to be working but really not). Thanks!

###################################################################
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^23\.254\.12\.43
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://maintenance.mysite.com [R=307,L]
####################################################################
like image 666
Tyler Avatar asked Jul 09 '10 14:07

Tyler


1 Answers

Just adding another RewriteCond to handle the second IP address should be fine, like so:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !=23.254.12.43
RewriteCond %{REMOTE_ADDR} !=192.168.0.1
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://maintenance.mysite.com [R=307,L]
like image 51
Tim Stone Avatar answered Oct 21 '22 03:10

Tim Stone