How to determine the IP address location? For example, Shanghai user login brother our website automatically jump to the domain name in Shanghai

Source: Internet
Author: User
How to determine the IP address location? For example, Shanghai user login to our website automatically jump to the domain name in Shanghai
Title, a website two domain name, the main domain name and the Shanghai domain name, how can realize the Shanghai user to use the main domain name to visit by the judge whether the user seat is in Shanghai and automatically jumps to the domain name of Shanghai.
------Solution--------------------
Using the Taobao API

function Get_ip_from ($ip = ") {
if (empty ($ip)) {
$ip = Self::getip ();
}
[Email protected]_get_contents ("http://ip.taobao.com/service/getIpInfo.php?ip=". $ip);
$ip _arr=json_decode (stripslashes ($ip _json), 1);
if ($ip _arr[' code ']==0)
{
return $ip _arr[' data ';
}
Else
{
return false;
}
}


------Solution--------------------
There are many IP libraries. Pure. Baidu Sina. Google, as for the jump can be INI configuration, can also be written in code.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.