Google 的 robots.txt googlebot 测试器在 Disallow: .idea 上抛出错误

Google's robots.txt Tester for googlebot throws error on Disallow: .idea

Google 的 robots.txt googlebot 测试器在 Disallow: .idea 上抛出错误。

但是,它报告了 0 个错误和 0 个警告。

您的 robots.txt 文件 确实 包含错误,但是 Google 的测试工具没有正确报告错误。

首先,错误。您有几个路径不以斜杠开头的指令,例如:

Disallow: CVS
Disallow: .svn
Disallow: .git
...

Google's robots.txt specification 说这是不允许的:

The [path] value, if specified, is to be seen relative from the root of the website for which the robots.txt file was fetched (using the same protocol, port number, host and domain names). The path value must start with "/" to designate the root.

要解决此问题,您需要始终指定以斜杠开头的路径。在您的情况下,您可能需要使用通配符,例如:

Disallow: /*CVS
Disallow: /*.svn
Disallow: /*.git
...

Google 测试工具似乎没有将这些报告为错误。 (红色条不表示错误,它只是表示哪个指令正在执行阻塞。)但是,这些 错误。他们的行为是未定义的,而且几乎肯定不是你想要的行为。