这是就绪度审计,不是提及监测
技术

为 GPTBot 与 PerplexityBot 配置 robots.txt 与 WAF

AI 搜索引擎会发送哪些 user-agent、如何在 robots.txt 中放行它们,以及如何确认 WAF 没有在静默地向 AI 爬虫返回 403。

作者 Alex Xu(英文)4 分钟阅读

爬虫被屏蔽,就意味着那个引擎无法引用你,无论你的内容有多好。发生这件事的地方有两个:robots.txt 和你的防火墙——而第二个恰恰是没人检查的那个。

AI 搜索引擎会发送哪些 user-agent?

  • OpenAI: GPTBot(训练)、OAI-SearchBot(搜索索引)、ChatGPT-User(用户实时触发的抓取)
  • Anthropic: ClaudeBot、Claude-User、Claude-SearchBot、anthropic-ai
  • Perplexity: PerplexityBot、Perplexity-User
  • Google: Google-Extended(用于 AI grounding;Googlebot 是另一个)
  • 其他: Bytespider(字节跳动)、CCBot(Common Crawl)、meta-externalagent(Meta)、Applebot-Extended(Apple)

*-User 这一类 agent 值得单独拿出来看:它们抓取某个 URL,是因为刚刚有个人问起了它, 所以屏蔽它们改变的是某个用户此刻看到的内容——而不只是之后被收录的内容。

How robots.txt decides whether a crawler may fetch a pageA request from GPTBot leads to reading robots.txt, where groups are tried in order. If a group names the agent, that group's Allow and Disallow rules apply. If no group names it, the request is allowed, because robots.txt is an opt-out file.GPTBot requests /pricing/Read robots.txtgroups are tried in order — first match winsA group names itUser-agent: GPTBotIts Allow / Disallowapplies to this requestNo group names itno GPTBot, no *Allowedrobots.txt is opt-out, not opt-inAn unlisted agent is allowed — unless a User-agent: * group disallows the path.So "we never blocked GPTBot" is not the same claim as "GPTBot is allowed".
The default is the part readers get backwards: an agent that no group names is allowed, because robots.txt is a list of refusals rather than a list of permissions.

图中标注保留英文,其中 user-agent、Allow、Disallow 等为技术术语,以便与 robots.txt 原文逐项对照。

如何在 robots.txt 中允许它们?

默认行为本来就允许一切,所以大多数站点不需要做任何改动。真正的失败模式是反过来的: 一条继承来的或照抄来的规则把它们挡住了。把意图写明确,这样它才看得见、可审查。

# AI search crawlers - explicitly allowed
User-agent: GPTBot
Allow: /

User-agent: OAI-SearchBot
Allow: /

User-agent: ClaudeBot
Allow: /

User-agent: PerplexityBot
Allow: /

User-agent: Google-Extended
Allow: /

# Everything else
User-agent: *
Allow: /
Disallow: /private/

Sitemap: https://your-domain.com/sitemap.xml

让 robots.txt 只保留在一处。指向一个单独的 sitemap 不花什么成本,却经常被忘记。

为什么我的防火墙会向 AI 爬虫返回 403?

通常的元凶是 bot 管理功能,而不是你的 robots.txt。基于挑战的 bot 防护会给请求打分,并可能向任何不是浏览器的东西发出 JavaScript 挑战。 服务端爬虫无法完成 JS 挑战,于是它们收到一个挑战页或 403,并记录一次抓取失败。

按这个顺序检查:bot-fight 模式或同类设置、被设为 under-attack 配置的安全级别、 按 user-agent 匹配的自定义 WAF 规则,以及把爬虫突发流量当成攻击的限流规则。

我应该屏蔽 AI 训练爬虫吗?

这是一个正当的选择,而且它与搜索可见性是两件事。屏蔽 CCBot 或 GPTBot 影响的是模型训练与 grounding;屏蔽 OAI-SearchBot 或 PerplexityBot 影响的是你究竟还能不能被引用到答案里。 先确定你真正反对的是哪一个,并且在这个过程中千万不要一不留神把 Googlebot 或 Bingbot 也屏蔽了。

如何验证爬虫没有被屏蔽?

  1. 抓取你自己的 robots.txt,确认没有任何一组规则挡住上面这些 agent。
  2. 从一台不是浏览器的服务器上,用 AI 爬虫的 user-agent 请求一个页面,确认返回的状态码是 200。
  3. 查看 cf-mitigated 响应头,它表示系统已经发出了挑战。
  4. 检查边缘安全事件日志,看有没有来自 Google、OpenAI 或 Perplexity 地址段的请求被拦截。

由 LLMention 扫描器(英文)自动执行第 1 步,并报告在站点根目录下,gptbot、claudebot、perplexitybot、oai-searchbot 和 google-extended 中哪些被禁止。它不执行第 2、3 步:它以自身的身份、 从自己的地址抓取你的站点,所以它发出的请求永远无法告诉你,你的防火墙会怎样对待一个真正的 AI 爬虫。这两步需要你自己来运行。

关于爬虫访问的问题

我需要允许哪些 user-agent?

至少包括:OpenAI 的 GPTBot 与 OAI-SearchBot、Anthropic 的 ClaudeBot 与 Claude-SearchBot、Perplexity 的 PerplexityBot,以及 Google 用于其 AI 产品的 Google-Extended。

robots.txt 已经允许它们了,为什么扫描仍然报告被屏蔽?

因为防火墙或 CDN 规则可能在读取 robots.txt 之前就拒绝请求。大型站点按 IP 地址验证爬虫,所以 WAF 配置也是答案的一部分,而不只是那个文件。

我应该允许所有 AI 爬虫吗?

这是策略决定,而不是技术问题。允许搜索爬虫、同时禁止训练爬虫,是一种常见且站得住脚的划分,robots.txt 可以表达它。

证据与来源

GEO can boost visibility by up to 40% overall in generative engine responses, and in the paper's Table 1 the best of the tested methods improve on the no-optimization baseline by 41% and 28%. — Generative Engine Optimization, KDD 2024

本站使用的权重遵循那项测量结果,所以「可引用性与证据」占 11%,而「AI 上下文文件」维度占 5%。完整的权重,以及单 URL 扫描看不到的那部分图景,都写在方法论页上。

Primary sources