이 체크 아웃해야합니다 :
http://www.php.net/manual/en/function.geoip-continent-code-by-name.php 단순히 2 자리 국가 코드를 반환합니다
$country = geoip_continent_code_by_name ($_SERVER['REMOTE_ADDR']);
$ 국가를 사용합니다. 다음은 사용할 수 있어야하는 것입니다.
<?php
//Get the country code of the user, using REMOTE_ADDR is the most reliable way to do this
$country = geoip_continent_code_by_name ($_SERVER['REMOTE_ADDR']);
//Create a switch case to deal with the country codes
switch((string)$country) {
case 'AU':
$url = "http://www.site.au";
break;
case 'CA':
$url = "http://www.site.ca";
break;
//default case means, if you didn't provide a case (country code in your example), do this (otherwise known as a "catch all")
default:
$url = "http://defaultsite.com";
} //End switchcase
//This if statement says as long as $url is not empty (! means not), update header location (this is the php way of forwarding)
if (!empty($url)){
header('Location: '.$url);
} //End if statement
?>
try, catch 블록을 제거한 것을 알 수 있습니다. 그러나 이는 사용자 환경 설정이지만 대부분의 사람들은 기본 케이스를 제공하는 이유 인 스위치 케이스를 사용하여 좋아하지 않습니다.
100 % 작동해야합니다.
GeoIP.php는 [MaxMind GeoIP] (http://dev.maxmind.com/geoip/)에서 생각합니다. – MamaWalter