: 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
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?
More posts by @Sherry384
1 Comments
Sorted by latest first Latest Oldest Best
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]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.