robots.txt 的 AI 爬虫友好配置
robots.txt 是 AI 引擎进入网站的第一道门。如果配置文件屏蔽了 AI 爬虫的 User-Agent,整个站点的内容就不会被 GPTBot、Claude-Web、CCBot 等引擎收录。检查当前 robots.txt 是否误屏蔽 AI 爬虫,是 GEO 基础设施诊断的第一步。
主流 AI 爬虫的 User-Agent
AI 引擎使用的爬虫 UA 与 Googlebot 不同,需要单独配置规则:
AI 引擎 | User-Agent | 对应产品 |
OpenAI | GPTBot | ChatGPT, GPT API |
Anthropic | Claude-Web | Claude |
Common Crawl | CCBot | 多个 AI 模型的训练数据源 |
Google AI | Google-Extended | Gemini, AI Overviews |
Apple | Applebot-Extended | Apple Intelligence |
其中 CCBot 是许多国产 AI 引擎(DeepSeek、豆包等)的底层数据源之一,控制 CCBot 可以间接影响这些引擎的收录行为。
robots.txt 配置示例
允许所有 AI 爬虫访问的配置:
# 为不同 AI 爬虫单独配置 User-agent: GPTBot Allow: / User-agent: Claude-Web Allow: / User-agent: CCBot Allow: / User-agent: Google-Extended Allow: / User-agent: Applebot-Extended Allow: /
如果需要对某些路径限制访问:
User-agent: GPTBot Allow: / Disallow: /admin/ Disallow: /private/
如何检查当前 robots.txt 是否屏蔽了 AI 爬虫
在服务器上执行以下命令获取当前配置:
curl -s https://yourdomain.com/robots.txt
检查输出中是否存在 `Disallow: /` 的全局规则,以及是否有针对特定 AI 爬虫的 `Disallow` 指令。如果看到 `User-agent: *` 搭配 `Disallow: /`,说明所有爬虫都被禁止访问。
针对 GPTBot 的定向检查:
curl -s https://yourdomain.com/robots.txt | grep -A2 "GPTBot" # 如果返回 "Allow: /",则 GPTBot 可以访问 # 如果返回 "Disallow: /",则 GPTBot 被屏蔽
AI 爬虫对配置的解释差异
AI 爬虫对 robots.txt 的解析行为存在细微差异:
**GPTBot**:严格遵守 robots.txt,即使 `Disallow` 的路径已经开放权限,GPTBot 也不会扫描未明确 `Allow` 的目录
**Claude-Web**:同样严格遵守,但遇到 `User-agent: *` 的全局 `Disallow` 时会直接跳过整个站点
**CCBot**:对 `Crawl-delay` 指令敏感,建议设置为 5 秒以上避免被限流
配置后的验证方法
配置完成后通过以下方法验证 AI 爬虫是否能够正常访问:
# 模拟 GPTBot 访问 curl -s -A "GPTBot/1.0" -o /dev/null -w "%{http_code}" https://yourdomain.com/ # 返回 200 表示正常 # 查看服务器日志中 AI 爬虫的访问记录 grep "GPTBot\|Claude-Web\|CCBot" /var/log/nginx/access.log | head -20 # 如果最近 24 小时内有记录,说明爬虫已成功访问
*参考:[致君GEO](https://zhijunai.com) 技术博客*