• 设置WordPress博客的Robots.txt

    Posted on 二月 17th, 2009 inetdemon No comments

    WordPress的robots设定主要是两个目的,一方面减少管理页面被抓取,另一方面降低博客的相似页面。好的robots.txt对于伪装静态(permalink)的wordpress博客来说就更重要了。下面介绍一下wordpress的robots.txt设定

    首先我们需要不过滤对一些管理页面,程序和和rss的索引,同时,我们又希望搜索引擎也索引我们上传的内容。如果有一些页面比较类似或者重复,也可以用robots.txt文件更好地控制搜索引擎访问和索引你的网站,通过在robots中指定Disallow规则将类似网页从搜索引擎的索引(Index)中删除。参考了国外一些博客的robots设置,将我博客的robots调整如下:

    User-agent: *
    Disallow: /*?*
    Disallow: /*?
    Disallow: /?s=
    Disallow: /tag/
    Disallow: /rss/
    Disallow: /feed/
    Disallow: /date/
    Disallow: /search/
    Disallow: /links-page/
    Disallow: /archive/
    Disallow: /archives/
    Disallow: /category/
    Disallow: /category/*/*
    Disallow: /trackback/
    Disallow: */trackback
    Disallow: /contact-form/
    Disallow: /page/
    Disallow: /pages/
    Disallow: */comments
    Disallow: /comments/
    Disallow: /comments/feed/
    Disallow: /wp-admin/
    Disallow: /wp-includes/
    Disallow: /wp-content/plugins/
    Disallow: /wp-content/themes/
    Disallow: /wp-content/cache/
    Allow: /wp-content/uploads/
    Disallow: /cgi-bin/
    
    # Google Googlebot
    User-agent: Googlebot
    Disallow: /feed/$
    Disallow: /*/feed/$
    Disallow: /*/feed/rss/$
    Disallow: /*/trackback/$
    Disallow: /*/*/feed/$
    Disallow: /*/*/feed/rss/$
    Disallow: /*/*/trackback/$
    Disallow: /*/*/*/feed/$
    Disallow: /*/*/*/feed/rss/$
    Disallow: /*/*/*/trackback/$
    Disallow: /*.php$
    Disallow: /*.js$
    Disallow: /*.inc$
    Disallow: /*.css$
    Disallow: /*.wmv$
    Disallow: /*.avi$
    Disallow: /*.cgi$
    Disallow: /*.txt$
    
    # Google Image
    User-agent: Googlebot-Image
    Allow: /*
    
    User-agent: Mediapartners-Google
    Allow: /
    
    User-agent: Adsbot-Google
    Allow: /
    
    User-agent: Googlebot-Image
    Allow: /
    
    User-agent: Googlebot-Mobile
    Allow: /
    
    User-agent: ia_archiver
    Disallow: /
    
    User-agent: duggmirror
    Disallow: /
    
    Sitemap: http://www.jefflei.com/sitemap.xml

    爬虫说明

    Adsbot-Google
    这个蜘蛛是Google专门抓取广告主AdWords登陆页面质量得分(landing page quality)的
    Googlebot
    Googles网页(Google Web Index)和新闻(google news)索引网页蜘蛛
    Googlebot-Image
    Google图片索引网页蜘蛛(Google image index)
    Googlebot-Mobile
    Google无线的索引爬虫(Google Mobile Index)
    Mediapartners-Google
    这个蜘蛛是Google专门抓取广告网站决定AdSense内容(Google Adsense Content)相关性等的专用爬虫

    检查Robots.txt的设置可以使用Google网站管理员工具robots分析工具,具体的使用请见google robots说明。

    需要注意的是,robots.txt只对遵守规矩的蜘蛛有用,对于一些流氓蜘蛛(见我另一篇关于soso spider爬虫的博客),基本等于没有作用。

    使用Robots Meta

    除了使用robots.txt,还有两种方法可以禁止爬虫索引,一种是在网页的meta中的robots指定NOFOLLOW/NOINDEX, 还有一种办法是在一个具体的link中指定NOFOLLOW。NOINDEX指示搜索引擎不要收录,这样搜索结果中就不会出现该页,而NOFOLLOW则意思说不要跟进索引链接,因此PR不会被计算。在一篇对Matt Cutts访谈中也介绍了一些关于robots的介绍。比如下面这句的意思就是不要索引本页,但是follow本页的链接:
    <meta name="googlebot" content="noindex,follow" />

    最后,推荐一个Wordpress中Header.php中的一些robots设置的小技巧
    <?php if(is_single() || is_page() || is_category() || is_home()) { ?>
      <meta name="robots" content="all,noodp" />
    <?php } ?>
    <?php if(is_archive()) { ?>
      <meta name="robots" content="noarchive,noodp" />
    <?php } ?>
    <?php if(is_search() || is_404()) { ?>
      <meta name="robots" content="noindex,noarchive" />
    <?php } ?>

    Leave a reply