WordPress博客设置Robots.txt的技巧和方法
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.domain.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本页的链接:
最后,引荐一个WordPress中Header.php中的一些robots设置的小技巧
<?php if(is_single() || is_page() || is_category() || is_home()) { ?>
<?php } ?>
<?php if(is_archive()) { ?>
<?php } ?>
<?php if(is_search() || is_404()) { ?>
<?php } ?>