作为建站公司,经常会遇到上线网站更改备案的情况,如果涉及到已经上线网站,需要变更备案那的确是个非常棘手的问题。掉收录,很影响网站权重,关闭网站对于企业也有很大影响,那么我们用一个障眼法~可以让审核IP打不开,百度蜘蛛打开就可以正常备案了。操作代码如下。
<?php function get_client_ip() { if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) $ip = getenv("HTTP_CLIENT_IP"); else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) $ip = getenv("HTTP_X_FORWARDED_FOR"); else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) $ip = getenv("REMOTE_ADDR"); else if (isset ($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) $ip = $_SERVER['REMOTE_ADDR']; else $ip = "unknown"; return ($ip); } header("Content-type: text/html; charset=utf-8"); $verification = '山东省';//修改省份 $ip = get_client_ip(); //获取当前用户的ip $antecedents = $_SERVER['HTTP_REFERER'];//访客来路地址 $result = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$ip);//IP数据库来自淘宝。 $address = json_decode($result,true); if($address['data']['region'] == $verification && strpos($antecedents, 'baidu') === false && strpos($antecedents, 'google') === false){ sleep(9999999999999999); ob_start(); header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 3600'); echo '网站备案中....'; exit; } ?>
发布评论