你可以禁止所有,然后只允许特定网站 . 我知道一种方法是禁止特定网站并允许所有网站 . 它的反向是有效的:E.G:
User-agent: *
Disallow: /
Allow: /siteOne/
Allow: /siteTwo/
Allow: /siteThree/
简单地禁止所有,然后允许站点似乎比所有所有站点更安全,他们必须考虑你不希望他们爬行的所有地方 .
以上这种方法是否可以对网站描述负责?“由于此网站的robots.txt而无法获得此结果的说明 - 了解详情 . ”在Google主页上的有机排名中
更新 - 我已使用Google网站管理员工具>抓取> robots.txt测试版 . 首先,当我输入siteTwo / default.asp时,它表示已阻止并突出显示'Disallow:/'行 . 离开并重新访问该工具后,它现在显示允许 . 很奇怪 . 所以,如果这说允许,我想知道为什么它在网站的描述中给出了上面的消息?
UPDATE2 - 上面的robots.txt文件的例子应该有dirOne,dirTwo,而不是siteOne,siteTwo . 知道所有关于robot.txt的两个很棒的链接是下面接受的答案中的unor的robot.txt规范,robots exclusion standard也是必读的 . 这两页都解释了这一点 . 总而言之,是的,你可以禁止并允许他们,但总是将禁赛放在最后 .
1 回答
(注意:您不允许/允许在robots.txt中抓取"sites",而是抓取网址.
Disallow
/Allow
的值为always the beginning of a URL path . )robots.txt specification未定义
Allow
.遵循此规范的消费者将忽略任何
Allow
字段 . 一些消费者,比如Google,扩展了规范并了解Allow
.对于那些不了解
Allow
的消费者:一切都被禁止了 .对于那些了解
Allow
的消费者:是的,您的robots.txt应该适用于他们 . 除了那些与Allow
字段匹配的网址外,一切都被禁止 .假设您的robots.txt托管在
http://example.org/robots.txt
,Google将 allowed 抓取以下网址:http://example.org/siteOne/
http://example.org/siteOne/foo
http://example.org/siteOne/foo/
http://example.org/siteOne/foo.html
Google会 not be allowed 抓取以下网址:
http://example.org/siteone/
(区分大小写)http://example.org/siteOne
(缺少尾部斜杠)http://example.org/foo/siteOne/
(不匹配路径的开头)