Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to redirect US country traffic to my country domain from mydomain.com. My website is in Wordpress and i would prefer .htaccess. i have applied the below code but it redirecting all IP addresses to mydomain.us. Will any body help?

GeoIPEnable On
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(US)$ 
RewriteRule ^(.*)$ http://mydomain.us [R,L]
# 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

My Domains mydomains.com and mydomains.us has same structure like categories and post etc. i want to redirect mydomain.com traffic from US IPs to mydomain.us (but whole domain)

Thanks for answers by https://stackoverflow.com/users/2862485/amith https://stackoverflow.com/users/2184393/cafe-coder

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
812 views
Welcome To Ask or Share your Answers For Others

1 Answer

You should really check out the docs

In your case, try the following rewrite rule:

GeoIPEnable On
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ 
RewriteRule ^(.*)$ http://mydomain.us/$1 [R,L]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...