My website is blocked in UAE (Dubai). So, is there any way to redirect to another domain in UAE country only. This same question is already asked at Redirect website to another website if blocked in particular region. But there i could not find any solution. is any solution available?
i have tried with redirection code
<?php
function ip_visitor_country()
{
$CountryCode = "Unknown";
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.geoplugin.net/json.gp?ip=".$ip);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$ip_data_in = curl_exec($ch); // string
curl_close($ch);
$ip_data = json_decode($ip_data_in,true);
$ip_data = str_replace('"', '"', $ip_data); // for PHP 5.2 see stackoverflow.com/questions/3110487/
if($ip_data && $ip_data['geoplugin_countryCode'] != null) {
$CountryCode = $ip_data['geoplugin_countryCode'];
}
return $CountryCode;
}
//echo ip_visitor_country(); // output Coutry code
if(ip_visitor_country()=="AE"){header("Location: http://www.example.com");exit();}
?>