To redirecting any sub domain according to country, install mod_geoip module (GeoIp Extentsion) inside server if it not installed. Write below code in .htaccess file:
GeoIPEnable On
GeoIPDBFile /GeoIp path/GeoIP.dat
#Redirection according to country
# For USA
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^USA$
RewriteRule ^(.*)$ http://us.mysite.com$1 [L]
# For India
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^IN$
RewriteRule ^(.*)$ http://in.mysite.com$1 [L]
# For Canada
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://ca.mysite.com$1 [L]
GeoIPEnable On
GeoIPDBFile /GeoIp path/GeoIP.dat
#Redirection according to country
# For USA
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^USA$
RewriteRule ^(.*)$ http://us.mysite.com$1 [L]
# For India
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^IN$
RewriteRule ^(.*)$ http://in.mysite.com$1 [L]
# For Canada
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://ca.mysite.com$1 [L]
i was looking for cakephp web development and landed up on your post and i think i must appreciate your work.keep rocking.
ReplyDelete