php - Different Drupal front page from different country -


i have drupal site, , want redirecting visitors different page based on country. have 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 on plain php file. how can in drupal? how can redirect visitors proper node?

i don't understand neither why not using existing solution still: have tried putting snippet inside page.tpl.php? make sure path required library correct. might wanna put net/geoip.php inside sites/all/libraries folder , change require_once "net/geoip.php" require_once "../../libraries/net/geoip.php". assuming page.tpl.php located inside sites/all/themes/yourtheme/


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -