robots.txt 中的常用规则 [英] Common rule in robots.txt
本文介绍了robots.txt 中的常用规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 robots.txt<禁止像
1.html, 2.html, ..., [0-9]+.html
(就正则表达式而言)这样的 URL/代码>?
How can I disallow URLs like 1.html, 2.html, ..., [0-9]+.html
(in terms of regexp) with robots.txt
?
推荐答案
原始 robots.txt 规范不支持正则表达式/通配符.但是,您可以屏蔽如下网址:
The original robots.txt specification doesn't support regex/wildcards. However, you could block URLs like these:
- example.com/1.html
- example.com/2367123.html
- example.com/3
- example.com/4/foo
- example.com/5/1
- example.com/6/
- example.com/7.txt
- example.com/883
- example.com/9to5
- …
与:
User-agent: *
Disallow: /0
Disallow: /1
Disallow: /2
Disallow: /3
Disallow: /4
Disallow: /5
Disallow: /6
Disallow: /7
Disallow: /8
Disallow: /9
如果您只想阻止以单个数字开头且后跟 .html
的 URL,只需附加 .html
,例如:
If you want to block only URLs starting with a single numeral followed by .html
, just append .html
, like:
User-agent: *
Disallow: /0.html
Disallow: /1.html
…
但是,这不会阻塞,例如,example.com/12.html
这篇关于robots.txt 中的常用规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文