怎么根据来访者IP跳转到不同的页面?

    实现代码如下:


    $ip = getIp();//dede自带的查询IP功能,直接调用
    $res1 file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=$ip");
    $res1 = json_decode($res1);
    $useraddre $res1->data->region;
    $useraddre = mb_convert_encoding($useraddre"GBK""UTF-8");
    $dzcity "上海";
    $contrastrstr($useraddre,$dzcity);
    if(!emptyempty($contra)){
    //上海的,跳转到这里
    header("Pragma: no-cache");
    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
    header('HTTP/1.1 301 Moved Permanently');
    header("Location: http://www.某某站.com/");
    exit;
    }
     

    这样写好后放到首页就能实现判断跳转了,