답변 1개 / 댓글 1개
채택된 답변
+20 포인트
Q&A에 올라온 베온님의 답변을 참조하여 만든 예제입니다.
잘 활용하세요 ^^
Copy
<?php
$country = json_decode(file_get_contents("http://freegeoip.net/json/" . $_SERVER['REMOTE_ADDR']), true);
switch($country['country_code']){
case "KR":
header('Location: http://www.example.com/');
break;
case "JP":
header('Location: http://www.example.com/jp/');
break;
case "CN":
header('Location: http://www.example.com/cn/');
break;
default:
header('Location: http://www.example.com/us/');
break;
}
?>
답변을 작성하려면 로그인이 필요합니다.