<?PHP//Define a function getip ()functionGetIP () {Global $ip;if(getenv("Http_client_ip")) {$ip=getenv("Http_client_ip");}Else if(getenv("Http_x_forwarded_for")) {$ip=getenv("Http_x_forwarded_for");}Else if(getenv("REMOTE_ADDR")){ $ip=getenv("REMOTE_ADDR");}Else{$ip= "Unknow";}return $ip;}$user _ip=GetIP ();$url= "http://ip.taobao.com/service/getIpInfo.php?ip=".$user _ip; $ipinfo=json_decode (file_get_contents($url)); //Var_dump ($ipinfo);//exit ();if($ipinfo->code== ' 1 '){ Echo' Query failed ';} Else { if($ipinfo->data->region== ' Guangdong province '){ //Header ("http/1.1 301 Moved permanently"); You want to challenge the URL address//header ("location:http://londit-53e57d6eeff96.com.1188.url-test.com/1.php"); } //other provinces and cities directly into the $ipinfo->data->region jump to the corresponding URL
Here you can continue if elseif continue to the remaining cities to finish writing to the corresponding IP address
Pro Test Available August 11, 2014 10:25:28
}