zoukankan      html  css  js  c++  java
  • PHP判断用户UA给搜索引擎和用户展示不同页面

       一种黑帽SEO站群常用的SEO手段。判断来路是搜索蜘蛛就让蜘蛛看到全部的页面代码,如果判断来路是真实的用户则跳转到注册页或者其他页面,既能达到想要的效果,又能做良好的seo优化。

      

    <?php
    $http = false;
    $http1 = $_SERVER['HTTP_USER_AGENT'];
    if(strpos($http1, 'Googlebot') !== false){
    $http = true;
    } else if(strpos($http1, 'Baiduspider') >0){
    $http = true;
    } else if(strpos($http1, 'Yahoo! Slurp') !== false){
    $http = true;
    } else if(strpos($http1, 'msnbot') !== false){
    $http = true;
    } else if(strpos($http1, 'Sosospider') !== false){
    $http = true;
    } else if(strpos($http1, 'YodaoBot') !== false || strpos($http1, 'OutfoxBot') !== false){
    $http = true;
    } else if(strpos($http1, 'Sogou web spider') !== false || strpos($http1, 'Sogou Orion spider') !== false){
    $http = true;
    } else if(strpos($http1, 'fast-webcrawler') !== false){
    $http = true;
    } else if(strpos($http1, 'Gaisbot') !== false){
    $http = true;
    } else if(strpos($http1, 'ia_archiver') !== false){ 
    $http = true;
    } else if(strpos($http1, 'altavista') !== false){
    $http = true;
    } else if(strpos($http1, 'lycos_spider') !== false){
    $http = true;
    } else if(strpos($http1, 'Inktomi slurp') !== false){
    $http = true;
    } else if(strpos($http1, 'googlebot-mobile') !== false){
    $http = true;
    } else if(strpos($http1, '360Spider ') !== false){
    $http = true;
    } else if(strpos($http1, 'haosouspider') !== false){
    $http = true;
    } else if(strpos($http1, 'Sogou News Spider') !== false){
    $http = true;
    } else if(strpos($http1, 'YoudaoBot') !== false){
    $http = true;
    } else if(strpos($http1, 'bingbot') !== false){
    $http = true;
    } else if(strpos($http1, 'YisouSpider') !== false){
    $http = true;
    } else if(strpos($http1, 'ia_archiver') !== false){
    $http = true;
    } else if(strpos($http1, 'EasouSpider') !== false){
    $http = true;
    } else if(strpos($http1, 'JikeSpider') !== false){
    $http = true;
    } else if(strpos($http1, 'Sogou blog') !== false){
    $http = true;
    }
    if($http == false){
    header("Location: http://www.sdfymj.com/");
    exit();
    }
    ?>
    

      以上代码包含了各大主流搜索引擎的蜘蛛,把其中www.sdfymj.com替换为你的网址即可,这段代码可以放在php网页中,或者网站的头部文件中即可。

  • 相关阅读:
    自动对一个文件夹下的N个word文件批量执行一个宏
    PHP正则匹配联系方式手机号、QQ、微信、邮箱、固定电话
    私信基本功能数据库设计
    ArcGIS三分式标注、四分式标注和同时上下标实现
    Word2019文档中将页面边框更改为文本边框的方法
    Arcgis彻底删除和卸载
    ArcMap中各种基本概念的介绍
    ArcGIS Python工具箱.pyt裁剪工具
    C# Object对象的ToString方法在转换日期时丢失毫秒
    2020年糖尿病领域中国学者学术影响力排名
  • 原文地址:https://www.cnblogs.com/68xi/p/14074000.html
Copyright © 2011-2022 走看看