禁止 robots.txt 中的查询字符串仅用于一个 url

Disallow query strings in robots.txt for only one url

所以我有一个 url、chickens.com/hatching,它具有可以用于索引的潜在查询字符串,即 chickens.com/hatching?type=fast。我绝对希望保留基础 url、chickens.com/hatching 索引,但没有查询参数。我想在其他页面上索引查询参数,而不是这个页面,所以所有页面的包罗万象都不起作用。其次,我正在重写 urls 以删除结尾的斜线,这会捕获 chickens.com/hatching/?type=fast 以及 chickens.com/hatching?type=fast 吗?

这可以解决我的问题吗?

Disallow: /hatching?*

我听说这只适用于 google 爬虫...是否有适用于所有爬虫的更强大的解决方案?

感谢您的帮助!非常感谢。

User-agent: *
Disallow: /hatching?
Disallow: /hatching/

此 robots.txt 将阻止所有路径以 /hatching?/hatching/ 开头的 URL,例如:

  • /hatching?
  • /hatching?foo=bar
  • /hatching/
  • /hatching/foo
  • /hatching/?foo=bar

它仅使用原始 robots.txt 规范中的功能,因此所有符合标准的机器人都应该能够理解这一点。