Hi,
I’ve been trying for ages to set up a simple country-based redirect of a page, but I’m failing badly. Would any kind sole out there have any idea what I am doing wrong?
I would be really, hugely grateful for any help…
Basically, I would like to redirect visitors from the UK to one page, visitors from the US to a different page and all other visitors to a third page
I followed the only instructions I could find on the web for dreamhost, using shell_exec and geoip-lookup, shown below, but am failing to get the page to redirect
I can get it to recognise the country and echo the correct geoip country code, but I just can’t get the page to redirect
[php]<?php
$output = shell_exec('geoip-lookup '.$_SERVER[‘REMOTE_ADDR’]);
echo($output);
if($output == ‘GB’)
{
header(“HTTP/1.1 301 Moved Permanently”);
header(‘Location: http://www.mysite.com/uk/’);
}
if($output == ‘US’)
{
header(“HTTP/1.1 301 Moved Permanently”);
header(‘Location: http://www.mysite.com/us/’);
}
else {
header(“HTTP/1.1 301 Moved Permanently”);
header(‘Location: http://www.mysite.com/other/’);
}
?>[/php]