跳转到内容

robots.txt

简明回答

robots.txt 告诉爬虫可以抓取哪些 URL 路径,已标准化为 RFC 9309。它只控制抓取,不控制索引。被禁止抓取的 URL 如果有其他页面链接,仍可能在没有内容的情况下被编入索引。

  • 放在每个主机名和协议的根目录 /robots.txt(https://example.com/robots.txt 不覆盖 https://shop.example.com/)。
  • 纯文本,UTF-8 编码。每组规则以一行或多行 user-agent 开头,后跟 allow / disallow 规则。
字段作用
user-agent规则组适用的爬虫;* 匹配没有更具体规则组的任何爬虫。
disallow爬虫不应抓取的路径前缀。
allow可以抓取的路径前缀,用于覆盖范围更大的 disallow。
sitemapSitemap 的绝对 URL,不属于任何规则组。

路径中支持 *(任意字符序列)和 $(URL 结尾)。

robots.txt 中的 noindex 不受支持;请使用 robots meta 标签或 X-Robots-Tag 响应头,具体步骤见 让页面不出现在 Google 中。

这份说明没有为百度的 AI 产品单列 token,也就没有说明怎样把它们和百度搜索区别对待。相比之下,Google 为 Gemini 单独设了一个 token(Google-Extended)。

user-agent: *
disallow: /search
allow: /search/about
sitemap: https://example.com/sitemap-index.xml

参考来源

  1. RFC 9309: Robots Exclusion ProtocolIETF · standard · ✓ 2026-10-25
  2. How Google interprets the robots.txt specificationGoogle · official · ✓ 2026-10-25
  3. Introduction to robots.txtGoogle Search Central · official · ✓ 2026-10-24
  4. Block Search indexing with noindexGoogle Search Central · official · ✓ 2026-10-25
  5. FAQs of BaiduspiderBaidu · official · ✓ 2026-10-27
  6. 站长指南Sogou · official · ✓ 2026-10-27
  7. Robots协议支持360 Search · official · ✓ 2026-10-27
  8. 头条搜索spider介绍Toutiao Search · official · ✓ 2026-10-27