robots.txt禁止谷域机器人根域,但允许谷歌图像机器人?

时间:2013-11-23 11:00:18

标签: robots.txt

是否有以下robot.txt工作?

User-agent: *
Disallow: /

User-agent: Googlebot-Image
Allow: /

我的想法是避免谷歌抓取我的cdn域,但允许谷歌图片仍然抓取并索引我的图片。

1 个答案:

答案 0 :(得分:1)

该文件必须被称为robots.txt,而不是robot.txt

请注意,User-agent: *定位所有机器人(与另一个User-agent记录不匹配),而不仅仅是Googlebot。因此,如果您希望允许其他漫游器抓取您的网站,则可能需要使用User-agent: Googlebot

所以这个robots.txt会允许“Googlebot-Image”所有内容,并禁止所有其他机器人的所有内容:

User-agent: Googlebot-Image
Disallow:

User-agent: *
Disallow: /

(请注意,Disallow:空字符串值相当于Allow: /,但Allow字段不是原始robots.txt规范的一部分,尽管有些解析器支持它,其中谷歌的。)

相关问题