AI 爬蟲的 robots.txt:該允許什麼、該封鎖什麼
替你在意的每個 AI 爬蟲設定獨立的 User-agent 群組。若希望被引用,就允許 OAI-SearchBot、Claude-SearchBot、PerplexityBot 等搜尋爬蟲,並另外決定 GPTBot、ClaudeBot、Google-Extended、Applebot-Extended 等訓練標記。點名的群組會取代該爬蟲的 * 群組。
robots.txt 是一種純文字檔,可追溯到 1994 年,並在 2022 年成為正式標準 RFC 9309。多數 AI 廠商都表示其爬蟲會遵守它,也有數家為搜尋與訓練分別公布標記。因此,只要規則的意義與你想的一致,robots.txt 就是表明 AI 政策最簡單的地方。
本頁內容
AI 爬蟲使用哪些 robots.txt 標記?
以下是各廠商文件中公布的標記。依據 RFC 9309,比對時不分大小寫。
- OpenAI:
OAI-SearchBot(ChatGPT 搜尋)、GPTBot(訓練)、ChatGPT-User(使用者要求的造訪;OpenAI 表示 robots.txt 可能不適用)。 - Anthropic:
Claude-SearchBot(搜尋)、ClaudeBot(訓練)、Claude-User(使用者要求的造訪)。 - Perplexity:
PerplexityBot(搜尋)、Perplexity-User(使用者要求的造訪;Perplexity 表示通常會忽略 robots.txt)。 - Google:
Googlebot(Search,包含其 AI 功能)與Google-Extended,後者是沒有獨立爬蟲的標記,用來控制內容是否用於 Gemini 訓練與 grounding。 - Apple:
Applebot(Spotlight、Siri、Safari 搜尋)與Applebot-Extended,後者不會爬取,而是控制內容是否用於訓練 Apple 的基礎模型。 - Meta:
meta-externalagent(訓練與產品索引)與meta-webindexer(Meta AI 搜尋)。 - Common Crawl:
CCBot,用於建立 Common Crawl 免費公開的網路資料典藏。
一份好的 AI robots.txt 長什麼樣子?
這個範例允許 AI 搜尋與使用者擷取、退出主要的訓練標記,並對所有人保持一個私人區域關閉:
User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: PerplexityBot
User-agent: ChatGPT-User
User-agent: Claude-User
Allow: /
Disallow: /account/
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: meta-externalagent
User-agent: CCBot
Disallow: /
User-agent: *
Allow: /
Disallow: /account/
Sitemap: https://example.com/sitemap.xml
連續的多行 User-agent 會組成同一個群組,因此下方的規則適用於其中每個爬蟲。如果你希望內容用於訓練,只要省略第二個群組即可。封鎖 Google-Extended 不會影響 Google Search:Google 表示它不影響被收錄於 Search,也不是排名訊號。同樣地,Apple 表示禁止 Applebot-Extended 的頁面仍可出現在其搜尋結果中。
爬蟲如何選擇要套用哪些規則?
RFC 9309 對此有精確的定義,多數令人意外的情況都可由這些細節解釋:
- 爬蟲會尋找
User-agent與其產品標記相符的群組,不分大小寫。若有多個群組相符,它們的規則會合併成一組。 - 只有在沒有任何群組相符時,爬蟲才會遵循
User-agent: *群組。點名的群組不會從*繼承任何內容。 - 在群組內,路徑比對最長的規則優先。對
/blog/post而言,Allow: /blog/勝過Disallow: /。 - 如果
Allow與Disallow規則的比對長度相同,應採用Allow。 - 路徑中的
*可比對任意字元,$表示結尾,因此Disallow: /*.pdf$涵蓋所有 PDF。
robots.txt 最常見的錯誤有哪些?
- 以為點名的群組會繼承
*。只寫了Allow: /的OAI-SearchBot群組,會開放所有路徑,包括你在*底下禁止的路徑。 - robots.txt 網址回傳 HTML 頁面,通常是以狀態碼 200 提供的 404 頁面。爬蟲在裡面找不到有效規則。
- robots.txt 回傳伺服器錯誤。RFC 9309 規定,此時爬蟲必須假設整個網站都被禁止。404 則不同:它代表沒有任何限制。
- 本想封鎖訓練,卻封鎖了搜尋標記,例如為了避免模型訓練而禁止
PerplexityBot或Claude-SearchBot。 - 指望 robots.txt 阻止使用者要求的擷取。OpenAI 與 Perplexity 都表示其 user agent 可能不會遵守。
- 忘了子網域。每個主機都有自己的 robots.txt;Anthropic 的文件也提醒網站經營者要為每個子網域加入規則。
除了允許與禁止,還能聲明 AI 使用政策嗎?
Cloudflare 提出在 robots.txt 加入 Content-Signal 這一行,包含三種訊號:search(建立搜尋索引並顯示連結與簡短摘錄)、ai-input(即時將內容用於 AI 答案)與 ai-train(訓練或微調模型)。Cloudflare 的託管 robots.txt 可以幫你加入。
User-agent: *
Content-Signal: search=yes, ai-input=yes, ai-train=no
Allow: /
和 robots.txt 中的一切一樣,這些只是偏好聲明,並非技術上的控制。Cloudflare 自己也指出,遵守 robots.txt 是自願的。這一行是選用的,加了也無妨,但它無法取代上述針對各爬蟲設定的群組。
變更要多久才生效?如何檢查?
RFC 9309 指出,爬蟲使用快取的 robots.txt 不應超過 24 小時,OpenAI 與 Perplexity 也都表示變更大約需要一天才會套用。也請記住,robots.txt 不是存取控制:防火牆仍可封鎖你的規則所允許的爬蟲。
AISeeWhy 會針對所測試的每個爬蟲,依 RFC 9309 解析你的 robots.txt,標出無法連線或被當成 HTML 提供的檔案,顯示你的規則與伺服器不一致之處,並提供可直接套用的差異。
常見問題
封鎖 GPTBot 或 ClaudeBot 會損害我在 AI 答案中的能見度嗎?
不會直接影響。兩家廠商都以獨立的搜尋爬蟲處理搜尋,分別是 OAI-SearchBot 與 Claude-SearchBot。封鎖訓練爬蟲屬於政策選擇。
Google-Extended 能阻止 AI 總覽嗎?
不能。Google 表示,Search 中的 AI 功能使用 Googlebot 與 nosnippet、noindex 等一般 Search 控制項。Google-Extended 涵蓋的是 Gemini 訓練與其他 Google 產品中的 grounding,不影響 Search。
AI 爬蟲支援 Crawl-delay 嗎?
它不屬於 RFC 9309。Anthropic 表示支援 Crawl-delay 作為非標準擴充;其他廠商請查閱其文件。
robots.txt 必須放在哪裡?
放在每個主機的根目錄,例如 https://example.com/robots.txt。放在子資料夾的檔案會被忽略,每個子網域都需要有自己的檔案。
資料來源
- RFC 9309:Robots Exclusion Protocol
- OpenAI:OpenAI 爬蟲總覽
- Google:常見爬蟲(包含 Google-Extended)
- Apple:關於 Applebot
- Cloudflare:託管 robots.txt 與 Content Signals