robots.txtとAIボット
robots.txtはWebサーバーのルートディレクトリに設置するテキストファイルで、クローラーに対してアクセス可否を伝えるための業界標準です。GooglebotをはじめOpenAI・Anthropic・Perplexityなどの主要AIクローラーはrobots.txtを遵守すると宣言しています。
主要AIボットのUser-Agent一覧
| User-Agent | 企業 |
|---|---|
| GPTBot | OpenAI(学習) |
| OAI-SearchBot | OpenAI(検索) |
| ChatGPT-User | OpenAI(ブラウジング) |
| ClaudeBot | Anthropic(学習) |
| anthropic-ai | Anthropic(検索) |
| PerplexityBot | Perplexity |
| Google-Extended | Google(Gemini学習) |
| Applebot-Extended | Apple(AI学習) |
| Bytespider | ByteDance |
| cohere-ai | Cohere |
| YouBot | You.com |
| CCBot | Common Crawl |
全AIボットを一括ブロックする設定
# 全AIボットをブロック
User-agent: GPTBot
Disallow: /
User-agent: OAI-SearchBot
Disallow: /
User-agent: ChatGPT-User
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: anthropic-ai
Disallow: /
User-agent: PerplexityBot
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: Applebot-Extended
Disallow: /
User-agent: Bytespider
Disallow: /
User-agent: cohere-ai
Disallow: /
User-agent: YouBot
Disallow: /
User-agent: CCBot
Disallow: /
特定ページのみ許可する場合
# /about と /contact は許可、それ以外はブロック
User-agent: GPTBot
Allow: /about
Allow: /contact
Disallow: /
Googleボットは通常通り許可しつつAIのみブロック
# 通常の検索クローラーは許可(省略することで全許可)
User-agent: *
Allow: /
# AIボットのみブロック
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
サイトマップURLの追加
Sitemap: https://yourdomain.com/sitemap.xml
robots.txtの確認方法
設置後は以下のURLでブラウザから確認できます。
https://yourdomain.com/robots.txt
Google Search Consoleの「robots.txtテスター」でも動作確認が可能です。
robots.txtの限界と補完策
robots.txtはあくまで「申告制」のブロックです。ルールを無視する悪意あるクローラーや、User-Agentを偽装したクローラーには効果がありません。より確実なブロックには以下を組み合わせることを推奨します:
- Next.js Middleware / Nginx でのHTTP 402レスポンス(Tollgate方式)
- Cloudflare WAFカスタムルール
- AI Access Monitorによる計測・可視化
Next.jsプロジェクトでのrobots.ts(推奨)
Next.js 13以降では src/app/robots.ts でプログラマティックに生成できます。
import { MetadataRoute } from "next";
export default function robots(): MetadataRoute.Robots {
return {
rules: [
{ userAgent: "*", allow: "/" },
{ userAgent: "GPTBot", disallow: "/" },
{ userAgent: "ClaudeBot", disallow: "/" },
{ userAgent: "PerplexityBot", disallow: "/" },
],
sitemap: "https://yourdomain.com/sitemap.xml",
};
}