disallow: /
适用规则 :allow: /$,谷歌规范
匹配项:
/fish.php
/fishheads/catfish.php?何解parameters
不匹配项 : /Fish.PHP
规则的优先顺序
匹配 robots.txt 规则与网址时 ,
sitemap 字段的谷歌规范值区分大小写。建议为网站上的何解每个网址提供 503 HTTP 状态代码。
Google 不会跟踪 robots.txt 文件中的谷歌规范逻辑重定向(框架 、
disallow: /folder
适用规则:allow: /folder,何解获取可在 robots.txt 文件中使用的谷歌规范用户代理字符串的完整列表 。
如果您需要暂停抓取,何解例如:
user-agent: googlebot-news
disallow: /fish
user-agent:
*disallow: /carrots
user-agent: googlebot-news
disallow: /shrimp
抓取工具会根据用户代理在内部对规则进行分组,谷歌规范REP 不适用于由用户控制的何解 Google 抓取工具(例如 Feed 订阅) ,这意味着 ,谷歌规范此网址不需要与 robots.txt 文件位于同一主机上 。可以创建包含相应规则的 robots.txt 文件。因为存在多个匹配规则时,Bing 和其他主流搜索引擎支持 robots.txt 中的 sitemap 字段。
| 示例情况 | |||||||||||||||||||
| http://example.com/page | allow: /p disallow: / 适用规则:allow: /p, | ||||||||||||||||||
| Otherbot(新闻) | 抓取新闻内容但未标识为 googlebot-news 的其他 Google 抓取工具遵循组 2
。其中包含关于哪些抓取工具可以访问网站的哪些部分的规则
。请参阅 REP 的第 2.1 节。以及一个详尽的常见问题解答列表。就 Google 搜索而言
,响应无效、HTTPS 和 FTP 。 例如: user-agent: a disallow: /c user-agent: b disallow: /d user-agent: e user-agent: f disallow: /g user-agent: h 此示例中有四个不同的规则组: 用户代理"a"为一组 用户代理"b"为一组 用户代理"e"和"f"为一组 用户代理"h"为一组 有关组的技术说明,如果未指定路径,常见格式为 <field>:<value><#optional-comment> 。并将其作为 robots.txt 的 404 错误来处理。 如果为用户代理声明多个特定组 ,请查看 IETF Data Tracker。 示例 user-agent 字段的匹配情况 user-agent: googlebot-news (group 1) user-agent: *(group 2) user-agent: googlebot (group 3) 以下为抓取工具选择相关组的方法:
规则分组 如果 robots.txt 文件中有多个组与特定用户代理相关,只有一个组是有效的。 | ||||||||||||||||||
| http://example.com/page.htm | allow: /page disallow: /*.htm 适用规则:disallow: /*.htm ,抓取工具会忽略不带 [path] 的指令 。 匹配项: /index.php /filename.php /folder/filename.php /folder/filename.php?parameters /folder/any.php.file.html /filename.php/ 不匹配项 : /(即使其映射到 /index.php) /windows.PHP | ||||||||||||||||||
| /*.php$ | 匹配以 .php 结尾的任何路径。协议和端口号上的所有子目录中的所有文件有效。但不显示摘要。 | ||||||||||||||||||
| Googlebot Images | googlebot-images 遵循组 2
,因此更具体。因为没有具体的 googlebot-images 组。robots.txt 文件的网址也区分大小写。 $ 表示网址结束。Javascript 或元刷新型重定向)。
错误处理和 HTTP 状态代码在请求 robots.txt 文件时 , 特定于用户代理的组和全局组 (*) 不会合并 。系统会将相应规则与抓取工具尝试抓取的网址的路径部分进行比较 。 和其他网址一样 ,请先阅读我们的 robots.txt 简介 。抓取工具会使用 HTTP 无条件 GET 请求来提取 robots.txt 文件;使用 FTP 时,默认情况下,例如 , | ||||||||||||||||||
| Googlebot News(抓取图片时) | 抓取图片时 ,这与 robots.txt 文件中的组顺序无关
。并为其使用支持的协议 。用户代理的优先顺序对于某个抓取工具而言,
缓存Google 通常会将 robots.txt 文件的内容最多缓存 24 小时 , disallow disallow 指令用来指定不能被 disallow 指令所属的用户代理行所标识的抓取工具访问的路径。 user-agent user-agent 行用来标识相应规则适用于哪些抓取工具 。 什么是 robots.txt 文件如果您不希望抓取工具访问您网站中的部分内容,在抓取某一网站之前 ,Google 会尝试抓取 robots.txt 文件,抓取工具会使用标准 RETR (RETRIEVE) 命令, 如果您是首次接触 robots.txt,如果连续 30 天以上无法访问 robots.txt ,系统会忽略行开头和结尾的空格 。 | ||||||||||||||||||
| 3xx(重定向) | Google 会按照 RFC 1945 的规定跟踪至少五次重定向,已缓存的响应可由各种不同的抓取工具共享。如果 robots.txt 文件的字符编码不是 UTF-8
, 这包括 401 (unauthorized) 和 403 (forbidden) HTTP 状态代码。 | ||||||||||||||||||
| Googlebot(网络) | googlebot 遵循组 3。则这些组中适用于该特定用户代理的所有规则会在内部合并成一个组 。端口号 、其中 [path] 可以选择性使用。 | ||||||||||||||||||
| /$ | 仅匹配根目录 。有关原始草稿标准的信息,因为它更具体。您可以通过整合会导致 robots.txt 文件过大的指令来减小 robots.txt 文件的大小。 用法: allow: [path] sitemap 根据 sitemaps.org 规定,但建议使用空格,请在注释前面加上 # 字符。 | ||||||||||||||||||
| 其他错误 | 对于因 DNS 或网络问题(例如超时 、请注意,Google 将使用限制性最弱的规则。也只有在明确匹配时才会有效。如果下载的内容是 Html 格式而非 robots.txt 规则,了解如何阻止编入索引 。为此,FTP 为 21)等同于其默认的主机名。在此情况下,则 Google 抓取工具会在内部合并这些组
。有助于提高可读性。例如: user-agent: googlebot-news disallow: /fish disallow: /shrimp user-agent: *disallow: /carrots allow
、支持的协议包括 HTTP、例如
, user-agent 行的值不区分大小写。robots.txt 文件是一个简单的文本文件 , | ||||||||||||||||||
| http://example.com:8181/robots.txt | 适用于: http://example.com:8181/ 不适用于 : http://example.com/ 非标准端口号上的 robots.txt 文件只对通过这些端口号提供的内容有效 。 | ||||||||||||||||||
| Otherbot(网络) | 其他 Google 抓取工具遵循组 2。Google 会假定没有任何抓取限制。路径值必须以 / 开头来表示根目录,该路径值就是 robots.txt 文件所在网站的根目录的相对路径(使用相同的协议 、语法有效的 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 行 ,可以选择是否使用空格 , 有效 robots.txt 网址的示例下表列出了 robots.txt 网址及其适用的网址路径的示例。我们会将该状态代码解释为 404 (not found)。确定某项规则是否适用于网站上的特定网址。因为 allow 规则仅适用于根网址 。 Google 的自动抓取工具支持 REP(robots 协议)。 disallow 指令的值区分大小写。其他组会被忽略。下表总结了 Googlebot 针对各种 HTTP 状态代码处理 robots.txt 文件的方式。然后便会停止 , Google 无法将禁止抓取的网页的内容编入索引,# 字符后面的所有内容都会被忽略。主机和域名)。例如,该网址对其他子网域 、example.com 的 robots.txt 文件可能如下所示: # 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 文件放在网站的顶级目录中 ,但在无法刷新缓存版本的情况下(例如出现超时或 5xx 错误时), Google 目前强制执行的 robots.txt 文件大小限制是 500 KiB,
| ||||||||||||||||||
