0

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('&quot;', '"', $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();}
?>
  • https://stackoverflow.com/questions/5398674/get-users-current-location – Russ J Feb 08 '19 at 18:48
  • 2
    How are they going to get to the redirect if they can't get to the site? – ceejayoz Feb 08 '19 at 19:07
  • then what was the solution for that? – Habibunisha yaseen Feb 09 '19 at 13:32
  • @Habibunishayaseen There's not a great solution here. If the UAE is banning your site, they're likely to ban its replacement. In the meantime, you don't have a technological approach here - you'd have to get out the word to UAE folks to use a different domain (or some sort of out-of-country VPN/proxy). – ceejayoz Feb 09 '19 at 21:52

0 Answers0