Kodda sadece iki şey değiştirdim ve tr.siteadi.com sayfasına yönlendi.
1. değiştirdiğim şey ip adresi oldu. $_SERVER['REMOTE_ADDR'] demişsiniz, bunu manuel olarak kendi internete bağlandığım ip adresiyle değiştirdim. İkincisi ise verdiğiniz adres. Bilmiyorum kodu buraya yazarken özellikle mi öyle yaptınız ama http: dan sonra iki tane slash koydum. Yani
http://api..... şeklinde Sorun olmadan çalıştı.
NOT: localhostta çalıştırırsanız else bloğunun çalışması normaldir. Çünkü IP adresini 127.0.0.1 olarak alır. Ya da Windows 7 ve üstünde ip adresi ::1 şeklinde döner. Bu yüzden web sayfası NO DATA şeklinde bir sonuç dönderiyor. NO DATA sonucu yüzünden else bloğuna düşüyorsunuz.
<?php
$ipaddress = "78.191.101.234";
$locationstr = "http://api.locatorhq.com/?user=aaaz2568&key=cb70014a000193e4a21f8c5d546128d7ce231dae&ip=".$ipaddress."&format=xml";
$xml = simplexml_load_file($locationstr);
$country = $xml->countryCode;
echo $country;
if (eregi ("TR", $country)) {
header("Location:http://tr.siteadi.com");
}
elseif (eregi ("ES", $country)) {
header("Location:http://es.siteadi.com");
}
elseif (eregi ("DE", $country)) {
header("Location:http://de.siteadi.com");
}
elseif (eregi ("FR", $country)) {
header("Location:http://fr.siteadi.com");
}
elseif (eregi ("JP", $country)) {
header("Location:http://jp.siteadi.com");
}
elseif (eregi ("UK", $country)) {
header("Location:http://uk.siteadi.com");
}
elseif (eregi ("MX", $country)) {
header("Location:http://mx.siteadi.com");
}
elseif (eregi ("NL", $country)) {
header("Location:http://nl.siteadi.com");
}
elseif (eregi ("RU", $country)) {
header("Location:http://ru.siteadi.com");
}
elseif (eregi ("BE", $country)) {
header("Location:http://be.siteadi.com");
}
else { echo "olmadi";}
?>