0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SEOスコアが下がった原因はCloudflareのrobots.txt改変だった

Last updated at Posted at 2025-09-18

1. 結論

PageSpeed Insights(PSI)のSEOスコアが、1/5〜1/10の確率で約8点ほど低下する現象が発生していました。その際、 robots.txtの最下段に文字化けのような断片が混入していると指摘を受けていました。

キャッシュ設定やNitroPackの最適化を疑いましたが、原因はCloudflareの「robots.txt で AI ボットのトラフィックを指示する ベータ」でした。

2. 状況

  • robots.txtはオリジンサーバのルートフォルダに静的ファイルとして設置済み
  • NitroPackではrobots.txtを最適化対象から除外
  • CloudflareのWAF(セキュリティ → カスタムルール)ではrobots.txtを一切扱っていない
  • Cloudflareのページルールでrobots.txtに対しキャッシュレベル:スキップを設定済

それにもかかわらず、以下のような挙動が発生:

  • ブラウザでrobots.txtをリロードすると、1/5〜1/10の確率で応答が来ない
  • 同じくらいの確率で、文字化けしたrobots.txtが返ってくる
  • PSIでは、SEOスコア低下とともにrobots.txtの不正が指摘される

3. 原因の特定

Cloudflareの「robots.txt で AI ボットのトラフィックを指示する(ベータ)」機能が有効になっていました。この機能は、GPTBot、ClaudeBot、Google-Extended などのAIクローラーに対して、Disallow: /を前置した独自のrobots.txtを合成して返す仕様です。
しかし、この合成処理が不安定で、末尾にバイナリ断片が混入し、文字化けが発生していました。

4. 解決策

以下の手順で問題を解消しました:

  1. Cloudflareダッシュボード > ご自身のドメイン > セキュリティ > 設定
    • robots.txt で AI ボットのトラフィックを指示する(ベータ)」を無効化
  2. 必要に応じて、Cloudflareのキャッシュを明示的にパージ(robots.txtのURLを指定)

この設定変更後、静的ファイルが安定して返るようになり、PSIのSEOスコアも安定化しました。

5. 実際に返ってきた文字化けrobots.txt

以下は、PSIで指摘された際に取得したrobots.txtです。
最下段にバイナリ断片のような文字列が混入しており、PSIでSEOスコア低下の原因になっていました。

# NOTICE: The collection of content and other data on this
# site through automated means, including any device, tool,
# or process designed to data mine or scrape content, is
# prohibited except (1) for the purpose of search engine indexing or
# artificial intelligence retrieval augmented generation or (2) with express
# written permission from this site’s operator.

# To request permission to license our intellectual
# property and/or other materials, please contact this
# site’s operator directly.

# BEGIN Cloudflare Managed content

User-agent: Amazonbot
Disallow: /

User-agent: Applebot-Extended
Disallow: /

User-agent: Bytespider
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: GPTBot
Disallow: /

User-agent: meta-externalagent
Disallow: /

# END Cloudflare Managed Content
!H     KzF Cc    )m L z   C ͅ   3Q u~X%  t  "   ԍ  S iJ G  LB}P   5 ! ڝ w " 1 h  焪    T H

6. 解消に至った経緯

色々検証しながら原発部位を特定し、最終的に、Cloudflare公式ドキュメント「Direct AI crawlers with managed robots.txt · Cloudflare bot solutions docsを確認したところ、コメントアウト部分の文言が、返ってきた文字化けrobots.txtと完全一致していました。
そこから「robots.txt で AI ボットのトラフィックを指示する ベータ」機能が原因と推測し、無効化したところ、現象が完全に解消しました。

7. まとめ

  • これは、Cloudflareの「robots.txt で AI ボットのトラフィックを指示する ベータ」を使っているすべてのアプリケーションに影響します
  • あくまでも2025/9/18(木)時点でベータ機能と明記されているため、有効化は慎重に検討するべきです

Cloudflareのおすすめポイント(補足)

Cloudflareは、Workers(≒Lambda@Edge)やR2(≒S3)など、高コスパなエッジコンピューティング機能を提供しており、WebセキュリティとWebパフォーマンス対策でコスパよく有用であるため、個人的にも強く推奨しています。
無料プランでもWAFやCacheのルール制御が標準搭載されており、様々なプロジェクトでコスパ良くセキュリティ(主にWAFとCDN)で活躍できるプロダクトです(Cloudflareと私は一切関係有りません)。

追記:robots.txtの安定性検証スクリプト

for i in {1..20}; do
  curl -s https://yourdomain.com/robots.txt | md5sum
done | sort | uniq -c

→ 出力が1種類なら安定化成功。複数種類なら応答分岐が残っている可能性あり。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?