How can I determine the IP address location? For example, if a Shanghai user logs on to our website, the domain name automatically jumps to Shanghai.

Source: Internet
Author: User
How can I determine the IP address location? For example, if a Shanghai user logs on to our website, the domain name automatically jumps to Shanghai, such as the question, one website has two domain names, the primary domain name and the Shanghai domain name, how can a user in Shanghai automatically jump to the domain name in Shanghai by checking whether the user is located in Shanghai when using the primary domain name for access.


Reply to discussion (solution)

Use taobao APIs

Function Get_Ip_From ($ ip = '') {if (empty ($ ip) {$ ip = self: Getip () ;}$ ip_json = @ file_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 ;}}

There are many ip address libraries. Pure. Baidu. Sina. For google, you can configure ini or write data in the 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.