怎样判断ip地址所在地?比如上海用户登录小弟我们的网站自动跳转到上海的域名

WBOY
Release: 2016-06-13 11:58:25
Original
1242 people have browsed it

怎样判断ip地址所在地?比如上海用户登录我们的网站自动跳转到上海的域名
如题,一个网站两个域名,主域名和上海域名,怎样能实现上海用户用主域名访问时通过判断该用户所在地是否在上海而自动跳转到上海的域名。
------解决方案--------------------
用taobao的api

<br />function Get_Ip_From($ip=''){<br />        if(empty($ip)){<br />            $ip = self::Getip();   <br />        }<br />        [email&#160;protected]_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$ip);<br />        $ip_arr=json_decode(stripslashes($ip_json),1);<br />        if($ip_arr['code']==0)<br />        {<br />            return $ip_arr['data'];<br />        }<br />        else<br />        {<br />            return false;<br />        }<br />    }<br /><br />
Copy after login

------解决方案--------------------
ip库有很多。纯真。baidu。新浪。google,至于跳转可以ini配置,也可以代码中写入。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template