robots.txt 設定拒絕,邊緣端仍向爬蟲回傳頁面
Your robots.txt said no. We watched the edge serve the page anyway.
作者在自家網站測試發現,robots.txt 拒絕的四個訓練爬蟲請求仍收到 200 和 46,660 bytes,顯示檔案規則不代表邊緣端已封鎖。文章提供兩條 curl 指令,分別查看即時 robots.txt 內容及帶指定 User-Agent 的請求回應,並以狀態碼和回傳字節數比較結果。
Every robots.txt discussion turns into a syntax argument — wildcards, group order, whether $
anchors. All of that is settled and documented. What almost nobody checks is the second half: does
the thing in front of your origin actually act on the file?
We checked it on our own site and got the uncomfortable answer.
The file said no to four crawlers
Our robots.txt is short and deliberate: User-agent: * is Allow: /, and four training tokens are
refused by name — GPTBot, Google-Extended, ClaudeBot, CCBot.
Then we sent eight requests to one URL, each wearing a real crawler's user agent, and recorded the
status code and the byte count. On 2026-11-04 the answer for every one of them was 200 with 46,660
bytes — including the four the file had just refused.
That measurement is easy to reproduce. Two commands:
curl -s https://your-domain.example/robots.txt
curl -s -o /dev/null -w '%{http_code} %{size_download}\n' -A 'GPTBot/1.2' https://your-domain.example/
First one prints what you asked for. Second prints what you got. If they disagree, nothing is
enforcing anything and the file is a statement of preference.
Why the gap exists, in Cloudflare's own words
Their documentation says it plainly: "robots.txt directives are voluntary. Crawlers can ignore
them. When Bot Preference Sync is enabled, **Disallow* also blocks AI training crawlers at
Cloudflare's edge."*
Read that twice, because the second sentence is the part people skip. Disallow writes a line into
a text file. It becomes an edge block only when a second switch is on. Disallow and Block are not
synonyms — one is a request, the other is a response that does not contain the page.
This is not a Cloudflare quirk. Google treats robots.txt for Googlebot as access control for
Search, because Googlebot fetching the page is the access. But that is a statement about Google's
crawler, and it only holds for a crawler that chooses to comply.
So we turned it into a check you can run on any domain
The tool page now has two halves. The left columns are what the file says, computed from the live
file for nine crawlers. The last column is what we actually got when we asked as that crawler — one
real request per crawler, same path, status code and byte count.
On our own domain, right now:
| Crawler | File says | Edge answered |
|---|---|---|
| Googlebot | allowed | 200 · 36,271 B |
| GPTBot | blocked | 200 · 36,271 B |
| ClaudeBot | blocked | 200 · 36,271 B |
| CCBot | blocked | 200 · 36,271 B |
| Google-Extended | blocked | not testable — no user agent of its own |
Three rows red. That is the whole argument in one table, and it takes a domain name to produce.
Try it: robots.txt checker →
Four things that will save you from misreading the result
Google-Extended has no user agent. Google's documentation is explicit: there is no separate HTTP
user agent for it, and crawling is done with existing Google user agents. So it cannot be tested by
sending a request with that name. A checker that reports a status for it is inventing a user agent.
Our request is not Googlebot. It comes from a Cloudflare Worker wearing Googlebot's user agent
string. A 403 can therefore be the site's own bot protection — Bot Fight Mode, a WAF rule — rather
than a robots.txt decision. That is still the answer worth having ("the edge refuses this
crawler"), but the cause is not the file.
A 200 does not mean the crawler got your content. A rule can pass the request and a later layer
can strip the body. Read the byte count, not just the code. Our own numbers above are byte counts for
exactly that reason.
One URL, one moment. A different path, or five minutes later, can answer differently.
What we changed after measuring
Nothing about the file. We decided the site should stay quotable by AI crawlers, which is a choice,
not an oversight — so the fix was to document the gap rather than pretend it was closed. The check
now runs on every deploy instead of once: our verification script asserts the live response, and the
tool page shows the comparison to anyone who wants it.
What you should do is the part we cannot do for you: if your file says no to a crawler and your edge
says 200, you have a stated preference and no enforcement. Either accept that, or add the layer
that answers with something other than a page.
來源:DEV Community · dev.to