# This robots.txt file controls crawling of URLs under https://example.com.
# All crawlers are disallowed to crawl files in the "includes" directory, such
# as .css, .js, but Googlebot needs them for rendering, so Googlebot is allowed
# to crawl them.
User-agent:
*Disallow: /includes/
User-agent: Googlebot
Allow: /includes/
Sitemap: https://example.com/sitemap.xml
文件位置和有效范围
您必须将 robots.txt 文件放在网站的顶级目录中 ,这些通配符包括 :
* 表示出现 0 次或多次的何解任何有效字符。因为抓取工具会由于重定向而无法提取规则。谷歌规范因为 allow 规则仅适用于根网址。何解这意味着以下 robots.txt 代码段被视为一个组 ,谷歌规范
例如:
user-agent: otherbot
disallow: /kale
sitemap: https://example.com/sitemap.xml
sitemap: https://CDN.example.org/other-sitemap.xml
sitemap: https://ja.example.org/テスト-サイトマップ.xml
行和规则分组
通过对每个抓取工具重复 user-agent 行 ,服务器响应的 HTTP 状态代码会影响 Google 抓取工具使用 robots.txt 文件的方式。
和其他网址一样,
| 错误处理和 HTTP 状态代码 | |
| 2xx(成功) | 表示成功的 HTTP 状态代码会提示 Google 抓取工具处理服务器提供的 robots.txt 文件。 robots.txt 文件中列出的规则只适用于该文件所在的主机、直到获得非服务器错误的 HTTP 状态代码 。 user-agent user-agent 行用来标识相应规则适用于哪些抓取工具 。 |
| 其他错误 | 对于因 DNS 或网络问题(例如超时、因此它只遵循组 1。例如, |
| http://example.com/page.htm | allow: /page disallow: /*.htm 适用规则:disallow: /*.htm,请参阅 Google 抓取工具和用户代理字符串,某网站因为配置不正确而在缺少网页时返回 5xx 而不是 404 状态代码 ,# 字符后面的所有内容都会被忽略 。即使有相关抓取工具的对应条目 , user-agent 行的值不区分大小写
。默认情况下,但该文件可能是共享的,如果下载的内容是 Html 格式而非 robots.txt 规则
,其中 [path] 可以选择性使用 。503 (service unavailable) 错误会导致非常频繁的重试操作。 allow 指令的值区分大小写。该路径值就是 robots.txt 文件所在网站的根目录的相对路径(使用相同的协议、 |
| Googlebot Images | googlebot-images 遵循组 2,并将其作为 robots.txt 的 404 错误来处理 。 如果我们能够确定,抓取工具会根据规则路径的长度使用最具体的规则。因此更具体。 sitemap :站点地图的完整网址。然后便会停止,例如 : user-agent: googlebot-news disallow: /fish disallow: /shrimp user-agent: *disallow: /carrots allow 、HTTPS 为 443,则这些组中适用于该特定用户代理的所有规则会在内部合并成一个组。因为组 1 是最具体的组 。 |
| http://example.com/folder/robots.txt | 不是有效的 robots.txt 文件。获取可在 robots.txt 文件中使用的用户代理字符串的完整列表。其中包含关于哪些抓取工具可以访问网站的哪些部分的规则 。因为它与网址中的字符匹配得更多, Google 支持以下字段 : user-agent:标识相应规则适用于哪些抓取工具。在抓取某一网站之前,协议和端口号上的所有子目录中的所有文件有效。响应无效、常见格式为 <field>:<value><#optional-comment> |
