robots.txt 允许除少数子目录外的所有目录

robots.txt allow all except few sub-directories

我希望我的站点在搜索引擎中被编入索引,但少数子目录除外。以下是我的 robots.txt 设置:

robots.txt在根目录

User-agent: *
Allow: /

在子目录中分开robots.txt(待排除)

User-agent: *
Disallow: /

这是正确的方式还是根目录规则会覆盖子目录规则?

User-agent: *
Disallow: /

如果您正在开发一个新网站并且不希望搜索引擎将您不完整的网站编入索引,则上述指令很有用。 此外,您还可以获得高级信息 here

您可以使用位于根目录中的 robots.txt 来管理它们。确保在 disallow 模式之前有 allow 模式。

不,这是错误的。

子目录中不能有 robots.txt。你的robots.txtmust be placed in the document root你的主人

如果您想禁止抓取路径以 /foo 开头的网址,请在您的 robots.txt (http://example.com/robots.txt):

中使用此记录
User-agent: *
Disallow: /foo

这允许抓取除

这样的 URL 之外的所有内容(因此不需要 Allow
  • http://example.com/foo
  • http://example.com/foo/
  • http://example.com/foo.html
  • http://example.com/foobar
  • http://example.com/foo/bar