php做根据ip地址做跳转问题。 是这样的。做这个是为了躲避北京审核。当北京地区ip访问m.*****.com时候显示的是A站(审核用),北京意外的地区访问的是B站,是真正推广的网站,B站北京地区是看不到的。求有实用的php命令段。自己手里又要给ASP的,但是用的iframe,对页面兼容不好。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个直接在域名解析层面配置会更好吧。如果是代码,需要加入一个ip段映射地址库,程序判断ip是否是北京,做302跳转。 用的一个淘宝的ip接口$r = taobaoIP('119.75.217.109'); print_r($r); /** * 根据ip获得信息 * @param [type] $clientIP [ip] * @return [type] [description] */ function taobaoIP($clientIP){ $taobaoIP = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIP; $IPinfo = json_decode(file_get_contents($taobaoIP),true); $data = $IPinfo['data']; return $data; }Array( [country] => 中国 [country_id] => CN [area] => 华北 [area_id] => 100000 [region] => 北京市 [region_id] => 110000 [city] => 北京市 [city_id] => 110100 [county] => [county_id] => -1 [isp] => 百度网络 [isp_id] => 100099 [ip] => 119.75.217.109) function getip() { if (!empty($_SERVER["HTTP_CLIENT_IP"])) { $cip = $_SERVER["HTTP_CLIENT_IP"]; } else if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { $cip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else if (!empty($_SERVER["REMOTE_ADDR"])) { $cip = $_SERVER["REMOTE_ADDR"]; } else { $cip = ""; } return $cip;}function taobaoIP($clientIP){ $taobaoIP = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIP; $IPinfo = json_decode(file_get_contents($taobaoIP),true); $data = $IPinfo['data']; return $data;}$data = taobaoIP(getip());if(isset($data['region']) && $data['region']=='北京市'){ header('location:http://beijing.com'); // 北京ip}else{ header('location:http://other.com'); // 其他ip} php 时间比较,这个有点特殊 .htaccess 404错误配置问题 急死人 Testlink复制测试集有问题 PHP生成JS问题 请高手把这个ASP.net翻译成PHP YouYaX开源论坛,经典版发布啦。 关于PHP数据采集的问题 SSDB 提供了非常详细的 PHP API 文档 Phpmailer 用QQ 企业邮箱发送给自己 会出错,是为啥呢? 能给我推荐一款国产的系统嘛 类似joomla或drupal的 ECShop的后台订单列表的订单状态不显示 apache 总是莫名关闭,这里是我的错误日志,请大神帮忙看看!
$r = taobaoIP('119.75.217.109');
print_r($r);
/**
* 根据ip获得信息
* @param [type] $clientIP [ip]
* @return [type] [description]
*/
function taobaoIP($clientIP){
$taobaoIP = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIP;
$IPinfo = json_decode(file_get_contents($taobaoIP),true);
$data = $IPinfo['data'];
return $data;
}Array
(
[country] => 中国
[country_id] => CN
[area] => 华北
[area_id] => 100000
[region] => 北京市
[region_id] => 110000
[city] => 北京市
[city_id] => 110100
[county] =>
[county_id] => -1
[isp] => 百度网络
[isp_id] => 100099
[ip] => 119.75.217.109
)
function getip() {
if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
$cip = $_SERVER["HTTP_CLIENT_IP"];
} else if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else if (!empty($_SERVER["REMOTE_ADDR"])) {
$cip = $_SERVER["REMOTE_ADDR"];
} else {
$cip = "";
}
return $cip;
}function taobaoIP($clientIP){
$taobaoIP = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIP;
$IPinfo = json_decode(file_get_contents($taobaoIP),true);
$data = $IPinfo['data'];
return $data;
}$data = taobaoIP(getip());
if(isset($data['region']) && $data['region']=='北京市'){
header('location:http://beijing.com'); // 北京ip
}else{
header('location:http://other.com'); // 其他ip
}