WordPress程序robots.txt的正确写法实例

admin
admin
admin
376
文章
102
评论
2021年3月30日16:29:15
评论
458

WordPress程序robots.txt的正确写法实例WordPress默认的robots写法非常简单,写法如下:

User-agent: *
Disallow: /wp-admin/(不允许访问的目录)
Allow: /wp-admin/admin-ajax.php(允许访问的目录)

这当然不能满足我们的需要,我们不能让搜索引擎过来抓取一些无效的内容,比如像/feed/、

我们写robots其实原则也比较简单,因为搜索引擎蜘蛛是根据robots的规则来对我们的网站进行抓取的,哪些网页允许他抓取,哪些网页不让他抓取都要写清楚,尤其是不允许抓取的网页我们要在robots里面声明清楚。废话不多说,直接贴代码。、、

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/,用于高速搜索引擎禁止抓取附件;

下面是品自行博客的robots的写法,仅供大家参考,robots最下面放了一句话,可以告诉搜索引擎网站地图的路径。

User-agent: *
Disallow: /cgi-bin/
Disallow: /wp-admin/
Disallow: /wp-content/cache/
Disallow: /wp-content/languages/
Disallow: /wp-content/plugins/
Disallow: /wp-content/themes/
Disallow: /wp-content/upgrade/
Disallow: /wp-includes/
Disallow: /comments/
Disallow: /category/
Disallow: /page/
Disallow: /feed/
Disallow: /author/
Disallow: /trackback/
Disallow: /*/feed/
Disallow: /*/trackback/

Sitemap: https://www.pinzixing.com/sitemap.xml
admin
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: