Redirect Visitors Based On Country?

GeoIP.
Upload all files in the package.
PHP:
$RedirectSites = array('US' => 'SITE1', 'UK' => 'SITE2', 'PL' => 'SITE3');
$Country = GetCountryCodeByIP($_SERVER['REMOTE_ADDR']);
if(isset($RedirectSites[$Country]))
{
    header('Location: '. $RedirectSites[$Country]);
    exit;
}
PHP:
function GetCountryCodeByIP($IP)
{
    include("base/geoip/geoip.inc");
    $gi = geoip_open("base/geoip/GeoIP.dat",GEOIP_STANDARD); 
    $country=geoip_country_code_by_addr($gi, $IP);
    geoip_close($gi);
    return $country;
}
 
Back
Top