有些时候我们展现的内容是供搜索引擎用了,很多用户是不必看到的,所以下面分享该php代码,蜘蛛正常抓取,用户访问调转指定页面代码
- $v = false;
- $tmp = $_SERVER['HTTP_USER_AGENT'];
- if(strpos($tmp, 'Googlebot') !== false){
- $v = true;
- } else if(strpos($tmp, 'Baiduspider') >0){
- //echo '百度';
- $v = true;
- } else if(strpos($tmp, 'Yahoo! Slurp') !== false){
- //echo '雅虎';
- $v = true;
- } else if(strpos($tmp, 'msnbot') !== false){
- //echo 'Msn';
- $v = true;
- } else if(strpos($tmp, 'Sosospider') !== false){
- //echo '搜搜';
- $v = true;
- } else if(strpos($tmp, 'YodaoBot') !== false || strpos($tmp, 'OutfoxBot') !== false){
- //echo '有道';
- $v = true;
- } else if(strpos($tmp, 'Sogou web spider') !== false || strpos($tmp, 'Sogou Orion spider') !== false){
- //echo '搜狗';
- $v = true;
- } else if(strpos($tmp, 'fast-webcrawler') !== false){
- //echo 'Alltheweb';
- $v = true;
- } else if(strpos($tmp, 'Gaisbot') !== false){
- //echo 'Gais';
- $v = true;
- } else if(strpos($tmp, 'ia_archiver') !== false){
- //echo 'Alexa';
- $v = true;
- } else if(strpos($tmp, 'altavista') !== false){
- //echo 'AltaVista';
- $v = true;
- } else if(strpos($tmp, 'lycos_spider') !== false){
- //echo 'Lycos';
- $v = true;
- } else if(strpos($tmp, 'Inktomi slurp') !== false){
- //echo 'Inktomi';
- $v = true;
- }
- if($v != true){
- header("Location: http://www.xiaobei668.com");
- }
- ?>
复制代码
|