WordPress博客网站常用Robots.txt规则

说明:我们有时候页面有些内容由于某些因素,都要防止被搜索引擎收录,而禁止搜索引擎收录比较简单的办法是在Robots.txt里设置规则,Robots协议(也称为爬虫协议、机器人协议等)的全称是“网络爬虫排除标准”(Robots Exclusion Protocol),网站通过Robots协议告诉搜索引擎哪些页面可以抓取,哪些页面不能抓取。这里说下方法。

这里以WordPress博客网站为例,在网站根目录Robots.txt里添加如下规则:

User-agent: *
Disallow: /wp-admin/
Disallow: /wp-content/
Disallow: /wp-includes/
Disallow: /*/comment-page-*
Disallow: /*?replytocom=*
Disallow: /category/*/page/
Disallow: /tag/*/page/
Disallow: /*/trackback
Disallow: /feed
Disallow: /*/feed
Disallow: /comments/feed
Disallow: /?s=*
Disallow: /*/?s=*\
Disallow: /attachment/

下面分别解释一下各项的作用:

1、Disallow: /wp-admin/、Disallow: /wp-content/和Disallow: /wp-includes/
用于告诉搜索引擎不要抓取后台程序文件页面。

2、Disallow: /*/comment-page-*和Disallow: /*?replytocom=*
禁止搜索引擎抓取评论分页等相关链接。

3、Disallow: /category/*/page/和Disallow: /tag/*/page/
禁止搜索引擎抓取收录分类和标签的分页。

4、Disallow: /*/trackback
禁止搜索引擎抓取收录trackback等垃圾信息

5、Disallow: /feed、Disallow: /*/feed和Disallow: /comments/feed
禁止搜索引擎抓取收录feed链接,feed只用于订阅本站,与搜索引擎无关。

6、Disallow: /?s=*和Disallow: /*/?s=*\
禁止搜索引擎抓取站内搜索结果

7、Disallow: /attachment/
禁止搜索引擎抓取附件页面,比如毫无意义的图片附件页面。



给TA打赏
共{{data.count}}人
人已打赏
cj

一个强大的数据库管理工具:Navicat Premium中文破解版

2019-10-22 23:27:28

cj

一个Aria2新的更好用的Web前端:AriaNg安装教程

2019-10-23 6:39:49

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索