How to redirect visitors to Country Specific Domains based on IP Address

Hlasroez

New Member
I am working on a personal project which requires me to redirect domains based on visitors location (IP address). Example - Canadian visitor must be directed to domain.ca or UK visitor must be sent to domain.co.uk

I looked up google and all i managed to find is redirecting based on IP Ranges, this is a very tedious task and will take a lot of my time away. Also, i will have to keep updating the IP ranges as and when new IP ranges are added by a country.

Is there any better method to achieve what i want? Any software or script that can do this?

Your help will be appreciated. For a fact - I am only looking to do .com and .in as of now.

Thanks! i think you can get this easily from ip2location database for $49/year There are some free sites that do this like http://www.selfseo.com/ip_to_country.php

Which can be called with curl problem is you never know when they will vanish. Can you shed more knowledge on curl call thing? I do not know how to do it. You can use the binary file free from here http://www.maxmind.com/app/geolite
Install instructions with code here http://www.maxmind.com/app/installation?city=1

They update every month, and it takes a few seconds to wget the updated file to your server when upgrading


I use
PHP Code: \[code\]    include("geoip.inc");
    $gi = geoip_open("/home/proxyl/xxx/GeoIP.dat",GEOIP_STANDARD);
    $country_code = geoip_country_code_by_addr($gi, "$ip"); 
\[/code\] Its better if you use Maxmind Geo-lite db + Nginx compiled with geoip module.
 
Top