机器人的常见规则.txt



如何禁止像 1.html, 2.html, ..., [0-9]+.html 这样的 URL(就正则表达式而言)与 robots.txt

原始robots.txt规范不支持正则表达式/通配符。但是,您可以阻止如下网址:

  • 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 ,例如:

User-agent: *
Disallow: /0.html
Disallow: /1.html
…

但是,这不会阻止例如example.com/12.html

最新更新