我可以在 robots.txt 中使用“Host"指令吗? [英] Can I use the “Host” directive in robots.txt?
问题描述
在robots.txt
上搜索特定信息,我偶然发现了一个Yandex 帮助页面‡ 关于此主题.它表明我可以使用 Host
指令告诉爬虫我的首选镜像域:
Searching for specific information on the robots.txt
, I stumbled upon a Yandex help page‡ on this topic. It suggests that I could use the Host
directive to tell crawlers my preferred mirror domain:
User-Agent: *
Disallow: /dir/
Host: www.example.com
此外,维基百科文章指出 Google 也了解 Host
指令,但没有太多(即没有)信息.
Also, the Wikipedia article states that Google too understands the Host
directive, but there wasn’t much (i.e. none) information.
在 robotstxt.org,我没有在 Host
上找到任何内容(或 Crawl-delay
如维基百科所述).
At robotstxt.org, I didn’t find anything on Host
(or Crawl-delay
as stated on Wikipedia).
- 是否鼓励使用
Host
指令? - Google 是否有专门针对此
robots.txt
的资源? - 与其他抓取工具的兼容性如何?
‡ 至少从 2021 年初开始,链接条目不再处理相关指令.
推荐答案
无法识别的标题将被忽略.
Unrecognised headers are ignored.
他们称之为标题",但该术语在任何地方都没有定义.但是正如在关于格式的部分中提到的,以及在与 User-agent
和 Disallow
相同的段落中,假设标题"意味着字段名称"似乎是安全的".
They call it "headers" but this term is not defined anywhere. But as it’s mentioned in the section about the format, and in the same paragraph as User-agent
and Disallow
, it seems safe to assume that "headers" means "field names".
所以是的,您可以使用Host
或任何 其他字段名称.
So yes, you can use Host
or any other field name.
- 支持此类字段的 Robots.txt 解析器,好吧,支持它们.
- 不支持此类字段的 Robots.txt 解析器必须忽略它们.
但请记住:由于它们不是由 robots.txt 项目指定的,因此您不能确定不同的解析器以相同的方式支持该字段.所以你必须手动检查每个支持的解析器.
But keep in mind: As they are not specified by the robots.txt project, you can’t be sure that different parsers support this field in the same way. So you’d have to check every supporting parser manually.
这篇关于我可以在 robots.txt 中使用“Host"指令吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!