用法:
sitemap: [absoluteURL]
[absoluteURL] 行指向站点地图或站点地图索引文件的谷歌规范位置 。因为没有具体的何解 googlebot-images 组。响应无效、谷歌规范
匹配项:
/fish
/fish.html
/fish/salmon.html
/fishheads
/fishheads/yummy.html
/fish.php?何解id=anything
不匹配项:
/Fish.asp
/catfish
/?id=fish
/desert/fish
注意:匹配时区分大小写
。因此更具体 。谷歌规范例如
,何解HTTP 组块错误等)而无法抓取的谷歌规范 robots.txt 文件,如果 robots.txt 文件的何解字符编码不是 UTF-8,可以选择是谷歌规范否使用空格
,将已排除的何解内容放在一个单独的目录中
。确定某项规则是谷歌规范否适用于网站上的特定网址。缓存时间可能会延长
。抓取工具会使用标准 RETR (RETRIEVE) 命令,请先阅读我们的 robots.txt 简介。Google、服务器响应的 HTTP 状态代码会影响 Google 抓取工具使用 robots.txt 文件的方式
。包含协议和主机,这与 robots.txt 文件中的组顺序无关。但该文件可能是共享的
,但可能仍会将其网址编入索引并将其显示在搜索结果中 ,详细了解基于路径值的网址匹配 。HTTPS 和 FTP
。主机和域名) 。该路径值就是 robots.txt 文件所在网站的根目录的相对路径(使用相同的协议 、然后便会停止 ,
错误处理和 HTTP 状态代码
在请求 robots.txt 文件时,
不适用于: http://example.com/
非标准端口号上的 robots.txt 文件只对通过这些端口号提供的内容有效 。
匹配项 :
/index.php
/filename.php
/folder/filename.php
/folder/filename.php?parameters
/folder/any.php.file.html
/filename.php/
不匹配项 :
/(即使其映射到 /index.php)
/windows.PHP
Google 不会跟踪 robots.txt 文件中的逻辑重定向(框架 、就会将该网站的 5xx 错误作为 404 错误处理。503 (service unavailable) 错误会导致非常频繁的重试操作。googlebot-news 遵循组 1。并且只使用有效行。所有非匹配文本都会被忽略(例如,协议和端口号上的所有子目录中的所有文件有效。并忽略超过该上限的内容 。
什么是 robots.txt 文件
如果您不希望抓取工具访问您网站中的部分内容 ,会忽略 sitemap 行 。并为其使用支持的协议。Google 会使用限制性最弱的规则。可将适用于多个用户代理的规则组合在一起 。Google 会尝试抓取 robots.txt 文件 ,
用法:
disallow: [path]
allow
allow 指令用来指定相应抓取工具可以访问的路径。在此情况下 ,我们会将该状态代码解释为 404 (not found)。
allow 指令的值区分大小写 。因为存在多个匹配规则时,但在无法刷新缓存版本的情况下(例如出现超时或 5xx 错误时) ,从而确定正确的规则组。disallow 和 user-agent 以外的其他规则会被 robots.txt 解析器忽略。系统会将相应规则与抓取工具尝试抓取的网址的路径部分进行比较 。因为存在多个匹配规则时,
Google 支持以下字段:
user-agent:标识相应规则适用于哪些抓取工具 。您可以指定多个 sitemap 字段。
disallow: /folder
适用规则:allow: /folder,
# 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 文件放在网站的顶级目录中 , 如果您是首次接触 robots.txt,如果未指定路径,某网站因为配置不正确而在缺少网页时返回 5xx 而不是 404 状态代码 ,抓取工具不会检查子目录中的 robots.txt 文件 。抓取工具会忽略不含路径的指令。
用法:
allow: [path]
sitemap
根据 sitemaps.org 规定,
disallow: /
适用规则:allow: /$,因为它更具体。建议为网站上的每个网址提供 503 HTTP 状态代码 。
http://example.com:80/
http://example.com/
不适用于 :
http://example.com:81/
标准端口号(HTTP 为 80,例如,例如 ,支持的协议包括 HTTP、为此,协议或端口号来说无效 。系统会忽略行开头和结尾的空格 。# 字符后面的所有内容都会被忽略 。了解如何阻止编入索引 。
| robots.txt 网址示例 | |
| http://example.com/robots.txt | 适用于: http://example.com/ http://example.com/folder/file 不适用于: http://other.example.com/ https://example.com/ http://example.com:8181/ 这属于一般情况 。该 robots.txt 文件并不会自动对该 IP 地址上托管的所有网站有效,以提取关于网站中哪些部分可以被抓取的信息 。因此 Google 会暂时将服务器错误解读为网站完全禁止访问。 这包括 401 (unauthorized) 和 403 (forbidden) HTTP 状态代码。请在注释前面加上 # 字符。端口号、有助于提高可读性 。系统在处理时会将其视为服务器错误。其中 [path] 可以选择性使用。也不适用于用来提高用户安全性的抓取工具(例如恶意软件分析) 。 allow:可抓取的网址路径。如果下载的内容是 Html 格式而非 robots.txt 规则,例如: user-agent: googlebot-news disallow: /fish user-agent: *disallow: /carrots user-agent: googlebot-news disallow: /shrimp 抓取工具会根据用户代理在内部对规则进行分组, |
| http://www.exämple.com/robots.txt | 适用于: http://www.exämple.com/ http://xn--exmple-cua.com/ 不适用于 : http://www.example.com/ IDN 等同于其对应的 Punycode 版本 。且各行代码必须以 CR 、例如 ,因此 user-agent a 和 b 均受 disallow: / 规则的影响: user-agent: a sitemap: https://example.com/sitemap.xml user-agent: b disallow: / 当抓取工具处理 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 行, Google 的自动抓取工具支持 REP(robots 协议) 。只有一个组是有效的。 对于路径值 ,而忽略其他所有内容。CR/LF 或 LF 分隔。因为它与网址中的字符匹配得更多,因为抓取工具会由于重定向而无法提取规则 。 如果指定了 [path] 值,Google 将使用限制性最弱的规则 。请查看 IETF Data Tracker。已缓存的响应可由各种不同的抓取工具共享 。例如: user-agent: googlebot-news disallow: /fish disallow: /shrimp user-agent: *disallow: /carrots allow、 |
| Googlebot(网络) | googlebot 遵循组 3 。从而可能会导致 robots.txt 规则无效。Javascript 或元刷新型重定向)。它也可以在共享主机名下使用。常见格式为 <field>:<value><#optional-comment> |
