Hi, I have a drupal site, and i want to redirecting visitors to a different page based on the country. I have this code:
require_once "Net/GeoIP.php";
$geoip = Net_GeoIP::getInstance("Net/GeoIP.dat");
try {
$geocode = $geoip->lookupCountryCode($_SERVER['REMOTE_ADDR']);
} catch (Exception $e) {
$geocode = 'EN';
}
switch ($geocode) {
case 'HU':
header('Location: http://www.example.com/hu');
break;
case 'GB':
header('Location: http://www.example.com/en');
break;
case 'AT':
header('Location: http://www.example.com/at');
break;
case 'CY':
header('Location: http://www.example.com/cy');
break;
case 'DE':
header('Location: http://www.example.com/de');
break;
case 'NL':
header('Location: http://www.example.com/nl');
break;
case 'CH':
header('Location: http://www.example.com/ch');
break;
case 'ES':
header('Location: http://www.example.com/es');
break;
case 'US':
header('Location: http://www.example.com/us');
break;
default:
header('Location: http://www.example.com/en');
}
This works well on plain php file. How can i this in drupal? How can i redirect the visitors to the proper node?