Mobile app version of vmapp.org
Login or Join
Sherry384

: Redirecting specific ip addresses to a different website. The hosting server is Apache Redirecting specific IP addresses to a different website. The hosting server is Apache. I want certain visitors

@Sherry384

Posted in: #Apache #IpAddress #Redirects

Redirecting specific IP addresses to a different website. The hosting server is Apache.

I want certain visitors with specific IP address's to be redirected to a different website. I will be adding more over time.

I found:
#Redirect whole networks of IP addresses to an external URL
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^10.20.30 [OR]
RewriteCond %{REMOTE_ADDR} ^125.62
RewriteRule ^folder/(.*) anotherdomain.com/folder/ [R,L]


Is there any simpler way to do this?

Also, can I redirect 2 different IP addresses to different sites?

Why is ! added before the IP address on some examples of the above?

What does the / do?

Does .htaccess mods work on ip6v addresses?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sherry384

1 Comments

Sorted by latest first Latest Oldest Best

 

@Angela700

Something more like this for a range..

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^204.246.160.([0-9]|1[0-9])
RewriteRule ^ www.domain.com%{REQUEST_URI} [L,R=301]


You can also use php, with something like this..

if ip = specific range
redirect to site 1
else
redirect to site 2


In response to your comment, use this..

COPY ALL OF THIS AS IS..

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^172.56.30.223$
RewriteRule ^(.*)$ www.cat.com/ [L,R=301]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme