im trying to display my domain to specific country with IP checking which if open by TH(Thai) it will show my domain example.com but if not, it will show another page, im currently on Thai, which to check if it works, i use SG(Singapore) VPN to see if it works or not,
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!is_bot($user_agent, $bots)) {
$access_key = '6adf16bff8db66'; // Replace with your ipinfo.io access key
$ch = curl_init('http://ipinfo.io/' . $ip . '?token=' . $access_key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$ip_details = json_decode($json, true);
if ($ip_details['country'] == 'TH') {
header('Location: https://example.com/');
exit;
}
}
with the codes above it keeps showing the other domain if TH is set as the designated country, but if i swap it to SG, it shows the example.com to all even if i use my TH IP, im confused
please help