tags:

views:

59

answers:

3

Well I am using the following code to redirect users who don't have my IP to a coming soon page:

rewritebase /
rewritecond %{REMOTE_HOST} !(^1\.2\.3\.4)
rewritecond %{REQUEST_URI} !/comingsoon\.html$ 
rewriterule .* http://www.andrew-g-johnson.com/comingsoon.html [R=302,L]

I want to make it so that I have two IP's that are allowed, any ideas how?

+1  A: 

You could specify a regular expression like:

(1\.2\.3\.4|5\.6\.7\.8)

but that becomes unwieldy the more exceptions you want.

what you might want to do instead use mod_access (assuming you're using Apache) with allow and deny directives.

order deny, allow
deny all
allow from 1.2.3.4
allow from 5.6.7.8
ErrorDocument 403 http://www.andrew-g-johnson.com/comingsoon.html

combined with a custom error document for 403 that says coming soon.

cletus
+1  A: 

I'd actually recommend Cletus' suggestion, but an alternative if you wanted to stick with .htaccess would also be to just add on more lines of conditions (benefit is it's more legible than concatenating them all into one long regex):

rewritebase /
rewritecond %{REMOTE_HOST} !(^1\.2\.3\.4)
rewritecond %{REMOTE_HOST} !(^5\.6\.7\.8)
# and so forth
rewritecond %{REQUEST_URI} !/comingsoon\.html$ 
rewriterule .* http://www.andrew-g-johnson.com/comingsoon.html [R=302,L]
One Crayon
A: 

RewriteCond directives are combined implicitly with AND. So you just have to add another RewriteCond directive to express this:

RewriteCond %{REMOTE_HOST} !^1\.2\.3\.4$
RewriteCond %{REMOTE_HOST} !=5.6.7.8
RewriteRule !^comingsoon\.html$ comingsoon.html [R=302,L]

Additionally, you should specify the begin an the end of the address usind ^ and $ or do a lexicographical comparison with =.

Gumbo