I could really use some help with a problem I'm having. I've read as many posts as i can find on this topic but unfortunatly I still cant get it to work. I would like to redirect visitors to different sites depending on their country. I just can't get this to work. Any help would be very much appreciated. Here is what I've got: Code: <?php require_once('geoip.inc'); $gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE); $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if ($country == 'ca') { header('Location: example.ca'); } if ($country == 'nz') { header('Location: example.co.nz'); } if ($country == 'uk') { header('Location: example.co.uk'); } if ($country == 'us') { header('Location: example.info'); } ?>
I figured out that I could fix my problem with the following: <?php require_once('geoip.inc'); $gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE); $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); $my_countries = 'us'; if (strtolower($country) == $my_countries) { header('Location: example.us'); } $my_countriess = 'nz'; if (strtolower($country) == $my_countriess) { header('Location: example.co.nz); } $my_countriesss = 'uk'; if (strtolower($country) == $my_countriesss) { header('Location: example.co.uk'); } $my_countriessss = 'ca'; if (strtolower($country) == $my_countriessss) { header('Location: example.ca'); } ?> Thanks anyway for your help