GeoIp redirect specific country Traffic to country domain?

Deadly 提交于 2019-11-29 12:58:39

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]
Cafe Coder

Your rewrite rules direct non-US IP's to http://mydomain.us.

If you want to redirect US IP's to http://mydomain.com try this:

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

Or, if what you want is to redirect US IP users to http://mydomain.us, try this:

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

It's always good to check the mod_rewrite docs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!