A robots.txt file tells search engines and AI crawlers which URL paths on your host they may fetch, helping manage crawl traffic rather than hide pages from search results. Under RFC 9309, crawlers match the most specific User-agent group and resolve Allow or Disallow conflicts by longest path length, with Allow winning any tie.

What Robots.txt Controls: Crawling Traffic vs. Search Indexing

A `robots.txt` file sits at the root of your host and governs crawling, not indexing. Before automated bots request pages on `https://example.com`, they check `https://example.com/robots.txt` for open paths.

Google's introduction to robots.txt explains that its main job is managing crawler traffic so bots avoid overloading your server. It is not a privacy wall and does not keep a web page out of Search.

If other sites or internal links point to a disallowed URL, Google can still index the address without reading the page. Those results often show without a description or trigger Search Console warnings.

Match each directive to its real job:

Never combine `Disallow` and `noindex` on the same URL. Googlebot must crawl the page or headers to read `noindex`, so blocking the crawl hides that directive. For open pages stuck unindexed, see our crawled currently not indexed guide.

Core Syntax: User-agent, Disallow, Allow, and Sitemap Directives

Under IETF RFC 9309, `robots.txt` must be a UTF-8 plain text file served at `/robots.txt` with `text/plain` media type. Rules apply only to the exact scheme, hostname, and port serving the file.

A file at `https://example.com/robots.txt` does not govern `https://app.example.com/` or `http://example.com/`. Subdomains and alternate ports need their own root file.

Per Google's robots.txt specification, Google enforces a 500 kibibyte (KiB) limit and ignores unsupported fields such as `Crawl-delay`. Four directives drive standard files:

```text User-agent: * Disallow: /private/ Allow: /private/public-guide/

Sitemap: https://example.com/sitemap.xml ```

Crawlers follow only the single most specific matching `User-agent` group. Named groups merge if repeated, and specific groups never inherit rules from `User-agent: *`.

Trailing Slashes, Wildcards, and Conflicting Rule Precedence

Most `robots.txt` bugs come from path matching rather than syntax errors. Unlike `User-agent` tokens, paths in `Allow` and `Disallow` are case-sensitive and always match from the start of the path.

Omitting a trailing slash widens a rule beyond a directory. `Disallow: /private` blocks `/private`, `/private/`, and `/private-notes.html`. `Disallow: /private/` matches only paths inside `/private/` and leaves `/private.html` open.

RFC 9309 and Google support two wildcards and line comments:

Inside the active group, line order does not matter. Crawlers pick the matching rule with the longest path string in characters.

| Rules in Group | Tested URL | Winning Rule | Result | | :--- | :--- | :--- | :--- | | `Disallow: /`<br>`Allow: /$` | `https://example.com/` | `Allow: /$` (2 chars vs. 1) | Allowed | | `Disallow: /`<br>`Allow: /$` | `https://example.com/pricing/` | `Disallow: /` (`/$` fails) | Blocked | | `Disallow: /docs/`<br>`Allow: /docs/api/` | `https://example.com/docs/api/auth` | `Allow: /docs/api/` (10 vs. 6) | Allowed | | `Allow: /page`<br>`Disallow: /.htm` | `https://example.com/page.htm` | `Disallow: /.htm` (6 vs. 5) | Blocked | | `Allow: /folder`<br>`Disallow: /folder` | `https://example.com/folder/item` | Equal length tie goes to `Allow` | Allowed |

Note that trailing `` wildcards add no specificity: `Disallow: /` behaves identically to `Disallow: /`.

Managing AI Training vs. AI Search Crawlers Without Blocking Google

Many teams copy a blanket AI block without realizing platforms separate search retrieval from model training. Targeting each user-agent token keeps search citations intact while opting out of training.

Per OpenAI's crawler documentation, OpenAI separates its tokens cleanly. `OAI-SearchBot` indexes pages for ChatGPT search citations, whereas `GPTBot` crawls content that may train OpenAI foundation models. `ChatGPT-User` handles live user-triggered fetches.

Google makes a similar split in its common crawlers list and Google-Extended documentation. `Googlebot` governs Google Search, while `Google-Extended` controls whether crawled content is used to train Google's generative AI foundation models and for non-Search grounding without affecting Search inclusion or rankings.

Use this setup to allow Google Search and ChatGPT Search while opting out of training crawls:

```text User-agent: Googlebot Allow: /

User-agent: OAI-SearchBot Allow: /

User-agent: GPTBot Disallow: /

User-agent: Google-Extended Disallow: /

User-agent: * Allow: /

Sitemap: https://example.com/sitemap.xml ```

Because specific groups ignore `User-agent: *`, adding explicit `Allow: /` under `Googlebot` and `OAI-SearchBot` keeps intent clear. OpenAI notes it can take about 24 hours for its search systems to adjust after a `robots.txt` update.

Compare 14 AI tokens in our OAI-SearchBot vs. GPTBot guide, or clarify `/llms.txt` in our llms.txt vs. robots.txt guide.

Common Robots.txt Mistakes That Hide Pages or Leak Paths

One misplaced line in `robots.txt` can stall crawling or break layout rendering. Watch for five recurring mistakes before deploying:

  1. Blocking JS and CSS folders. Disallowing `/_next/static/` or `/assets/` prevents Googlebot from rendering pages properly.
  2. Leaving staging blocks live. Shipping `Disallow: /` under `User-agent: *` halts organic crawling immediately.
  3. Expecting `` rules to cascade. Adding a named `User-agent: Googlebot` block causes Googlebot to ignore every rule under `User-agent: `.
  4. Splitting groups with `Sitemap:`. Crawlers ignore `Sitemap:` while parsing groups, so two adjacent `User-agent:` lines separated only by `Sitemap:` merge into one group.
  5. Serving `5xx` errors on `/robots.txt`. Google treats `4xx` errors (except `429`) as open access, but `5xx` errors halt crawling for 12 hours before using a cached copy.

Remember that `/robots.txt` is public. Avoid listing sensitive admin slugs inside `Disallow:`. If indexed sitemap pages still stall, check our sitemap submitted but not indexed guide.

How to Test Pasted Robots.txt Rules Before Deploying

Test edge-case URLs before pushing `robots.txt` changes live. Google caches `/robots.txt` for up to 24 hours, so bad wildcards linger after a rollback.

Evaluate draft files locally in SearchBop's Robots.txt Tester. Because it checks pasted rules in your browser, you can validate behavior before editing DNS or production configs.

Verify these four test cases:

After deploying, run `curl -I https://example.com/robots.txt` to confirm HTTP `200 OK`, `text/plain` content type, and a file under 500 KiB. Then inspect Google Search Console's `robots.txt` report to verify live parsing.

Frequently asked questions

Does Disallow in robots.txt remove a page from Google Search?

No. Disallow only stops crawlers from fetching the URL. If other pages link to it, Google can still index the address without a snippet. Use a noindex tag or password protection and keep crawling open so Google can read it.

How do crawlers resolve conflicting Allow and Disallow rules?

Under RFC 9309, line order is ignored inside a matched User-agent group. Crawlers pick the matching rule with the longest path string in characters. If Allow and Disallow match with equal length, Allow wins.

Can I block GPTBot without blocking Googlebot or ChatGPT Search?

Yes. Create separate User-agent blocks: set Allow: / for Googlebot and OAI-SearchBot, and Disallow: / for GPTBot. OpenAI evaluates OAI-SearchBot and GPTBot independently, and its search systems take about 24 hours to adjust after a robots.txt update.

What happens if robots.txt returns a 404 or 500 error?

Google treats 4xx errors (except 429) as if no robots.txt exists, leaving public paths open. For 5xx server errors, Google pauses crawling for 12 hours and then uses its last cached copy for up to 30 days.

What is the difference between Disallow: /folder and Disallow: /folder/?

Disallow: /folder blocks any path starting with /folder, including /folder.html and /folder-guide/. Adding the trailing slash in Disallow: /folder/ narrows the rule strictly to URLs inside /folder/.

Test Your Robots.txt Rules Before You Ship

Paste your draft rules, enter a public HTTPS URL, and see which Allow or Disallow line decides access for Googlebot, OAI-SearchBot, or GPTBot in SearchBop's free Robots.txt Tester. For ongoing technical audits and ASO workflows without subscription bloat, explore SearchBop—a desktop SEO and App Store Optimization assistant with free calculators.

Try SearchBop

Sources: Google Search Central — Introduction to robots.txt, Google Search Central — How Google interprets the robots.txt specification, Google Search Central — List of Google's common crawlers and user agents, Google Crawling Infrastructure — How the Google-Extended Product Token Works, IETF RFC 9309 — Robots Exclusion Protocol, OpenAI Platform Docs — Overview of OpenAI Crawlers, SearchBop — Robots.txt Tester

Robots.txt Guide: Disallow Rules, AI Crawlers & Testing Syntax

A robots.txt file tells search engines and AI crawlers which URL paths on your host they may fetch, helping manage crawl traffic rather than hide pages from search results. Under RFC 9309, crawlers match the most specific User-agent group and resolve Allow or Disallow conflicts by longest path length, with Allow winning any tie.

What Robots.txt Controls: Crawling Traffic vs. Search Indexing

A `robots.txt` file sits at the root of your host and governs crawling, not indexing. Before automated bots request pages on `https://example.com`, they check `https://example.com/robots.txt` for open paths.

Google's introduction to robots.txt explains that its main job is managing crawler traffic so bots avoid overloading your server. It is not a privacy wall and does not keep a web page out of Search.

If other sites or internal links point to a disallowed URL, Google can still index the address without reading the page. Those results often show without a description or trigger Search Console warnings.

Match each directive to its real job:

  • Use `Disallow` in `robots.txt` to skip heavy filter URLs, internal search pages, or media files you want kept out of Google Images.
  • Use `noindex` via `<meta name="robots" content="noindex">` or `X-Robots-Tag` headers to exclude public pages from Search.
  • Use authentication whenever staging sites or admin tools hold private data.

Never combine `Disallow` and `noindex` on the same URL. Googlebot must crawl the page or headers to read `noindex`, so blocking the crawl hides that directive. For open pages stuck unindexed, see our crawled currently not indexed guide.

Core Syntax: User-agent, Disallow, Allow, and Sitemap Directives

Under IETF RFC 9309, `robots.txt` must be a UTF-8 plain text file served at `/robots.txt` with `text/plain` media type. Rules apply only to the exact scheme, hostname, and port serving the file.

A file at `https://example.com/robots.txt` does not govern `https://app.example.com/` or `http://example.com/`. Subdomains and alternate ports need their own root file.

Per Google's robots.txt specification, Google enforces a 500 kibibyte (KiB) limit and ignores unsupported fields such as `Crawl-delay`. Four directives drive standard files:

  • `User-agent`: Names the crawler token, such as `Googlebot` or `*` (case-insensitive).
  • `Disallow`: Blocks a URL path prefix; an empty `Disallow:` value blocks nothing.
  • `Allow`: Grants crawl access, commonly overriding a broader directory disallow.
  • `Sitemap`: Lists absolute `https://` sitemap URLs for all bots.

```text User-agent: * Disallow: /private/ Allow: /private/public-guide/

Sitemap: https://example.com/sitemap.xml ```

Crawlers follow only the single most specific matching `User-agent` group. Named groups merge if repeated, and specific groups never inherit rules from `User-agent: *`.

Trailing Slashes, Wildcards, and Conflicting Rule Precedence

Most `robots.txt` bugs come from path matching rather than syntax errors. Unlike `User-agent` tokens, paths in `Allow` and `Disallow` are case-sensitive and always match from the start of the path.

Omitting a trailing slash widens a rule beyond a directory. `Disallow: /private` blocks `/private`, `/private/`, and `/private-notes.html`. `Disallow: /private/` matches only paths inside `/private/` and leaves `/private.html` open.

RFC 9309 and Google support two wildcards and line comments:

  • ``: Matches zero or more characters, such as `Disallow: /?sort=`.
  • `$`: Anchors to the URL end, such as `Allow: /$` or `Disallow: /*.pdf$`.
  • `#`: Marks comments until the end of the line.

Inside the active group, line order does not matter. Crawlers pick the matching rule with the longest path string in characters.

| Rules in Group | Tested URL | Winning Rule | Result | | :--- | :--- | :--- | :--- | | `Disallow: /`<br>`Allow: /$` | `https://example.com/` | `Allow: /$` (2 chars vs. 1) | Allowed | | `Disallow: /`<br>`Allow: /$` | `https://example.com/pricing/` | `Disallow: /` (`/$` fails) | Blocked | | `Disallow: /docs/`<br>`Allow: /docs/api/` | `https://example.com/docs/api/auth` | `Allow: /docs/api/` (10 vs. 6) | Allowed | | `Allow: /page`<br>`Disallow: /.htm` | `https://example.com/page.htm` | `Disallow: /.htm` (6 vs. 5) | Blocked | | `Allow: /folder`<br>`Disallow: /folder` | `https://example.com/folder/item` | Equal length tie goes to `Allow` | Allowed |

Note that trailing `` wildcards add no specificity: `Disallow: /` behaves identically to `Disallow: /`.

Managing AI Training vs. AI Search Crawlers Without Blocking Google

Many teams copy a blanket AI block without realizing platforms separate search retrieval from model training. Targeting each user-agent token keeps search citations intact while opting out of training.

Per OpenAI's crawler documentation, OpenAI separates its tokens cleanly. `OAI-SearchBot` indexes pages for ChatGPT search citations, whereas `GPTBot` crawls content that may train OpenAI foundation models. `ChatGPT-User` handles live user-triggered fetches.

Google makes a similar split in its common crawlers list and Google-Extended documentation. `Googlebot` governs Google Search, while `Google-Extended` controls whether crawled content is used to train Google's generative AI foundation models and for non-Search grounding without affecting Search inclusion or rankings.

Use this setup to allow Google Search and ChatGPT Search while opting out of training crawls:

```text User-agent: Googlebot Allow: /

User-agent: OAI-SearchBot Allow: /

User-agent: GPTBot Disallow: /

User-agent: Google-Extended Disallow: /

User-agent: * Allow: /

Sitemap: https://example.com/sitemap.xml ```

Because specific groups ignore `User-agent: *`, adding explicit `Allow: /` under `Googlebot` and `OAI-SearchBot` keeps intent clear. OpenAI notes it can take about 24 hours for its search systems to adjust after a `robots.txt` update.

Compare 14 AI tokens in our OAI-SearchBot vs. GPTBot guide, or clarify `/llms.txt` in our llms.txt vs. robots.txt guide.

Common Robots.txt Mistakes That Hide Pages or Leak Paths

One misplaced line in `robots.txt` can stall crawling or break layout rendering. Watch for five recurring mistakes before deploying:

  1. Blocking JS and CSS folders. Disallowing `/_next/static/` or `/assets/` prevents Googlebot from rendering pages properly.
  2. Leaving staging blocks live. Shipping `Disallow: /` under `User-agent: *` halts organic crawling immediately.
  3. Expecting `` rules to cascade. Adding a named `User-agent: Googlebot` block causes Googlebot to ignore every rule under `User-agent: `.
  4. Splitting groups with `Sitemap:`. Crawlers ignore `Sitemap:` while parsing groups, so two adjacent `User-agent:` lines separated only by `Sitemap:` merge into one group.
  5. Serving `5xx` errors on `/robots.txt`. Google treats `4xx` errors (except `429`) as open access, but `5xx` errors halt crawling for 12 hours before using a cached copy.

Remember that `/robots.txt` is public. Avoid listing sensitive admin slugs inside `Disallow:`. If indexed sitemap pages still stall, check our sitemap submitted but not indexed guide.

How to Test Pasted Robots.txt Rules Before Deploying

Test edge-case URLs before pushing `robots.txt` changes live. Google caches `/robots.txt` for up to 24 hours, so bad wildcards linger after a rollback.

Evaluate draft files locally in SearchBop's Robots.txt Tester. Because it checks pasted rules in your browser, you can validate behavior before editing DNS or production configs.

Verify these four test cases:

  • Homepage vs. subfolder: Confirm `Allow: /$` plus `Disallow: /` allows `https://example.com/` for `Googlebot` while blocking `/draft/`.
  • Query parameters: Test `Disallow: /*?utm_` against `/blog/post/` (allowed) and `/blog/post/?utm_source=x` (blocked).
  • Specificity override: With `Disallow: /private/` and `Allow: /private/public-guide/`, confirm `/private/public-guide/` is allowed while `/private/report/` stays blocked.
  • AI crawler split: Test your file as `OAI-SearchBot` (allowed) and `GPTBot` (disallowed) on `/guides/`.

After deploying, run `curl -I https://example.com/robots.txt` to confirm HTTP `200 OK`, `text/plain` content type, and a file under 500 KiB. Then inspect Google Search Console's `robots.txt` report to verify live parsing.

Frequently asked questions

Does Disallow in robots.txt remove a page from Google Search?

No. Disallow only stops crawlers from fetching the URL. If other pages link to it, Google can still index the address without a snippet. Use a noindex tag or password protection and keep crawling open so Google can read it.

How do crawlers resolve conflicting Allow and Disallow rules?

Under RFC 9309, line order is ignored inside a matched User-agent group. Crawlers pick the matching rule with the longest path string in characters. If Allow and Disallow match with equal length, Allow wins.

Can I block GPTBot without blocking Googlebot or ChatGPT Search?

Yes. Create separate User-agent blocks: set Allow: / for Googlebot and OAI-SearchBot, and Disallow: / for GPTBot. OpenAI evaluates OAI-SearchBot and GPTBot independently, and its search systems take about 24 hours to adjust after a robots.txt update.

What happens if robots.txt returns a 404 or 500 error?

Google treats 4xx errors (except 429) as if no robots.txt exists, leaving public paths open. For 5xx server errors, Google pauses crawling for 12 hours and then uses its last cached copy for up to 30 days.

What is the difference between Disallow: /folder and Disallow: /folder/?

Disallow: /folder blocks any path starting with /folder, including /folder.html and /folder-guide/. Adding the trailing slash in Disallow: /folder/ narrows the rule strictly to URLs inside /folder/.

Test Your Robots.txt Rules Before You Ship

Paste your draft rules, enter a public HTTPS URL, and see which Allow or Disallow line decides access for Googlebot, OAI-SearchBot, or GPTBot in SearchBop's free Robots.txt Tester. For ongoing technical audits and ASO workflows without subscription bloat, explore SearchBop—a desktop SEO and App Store Optimization assistant with free calculators.

Try SearchBop

Sources: Google Search Central — Introduction to robots.txt, Google Search Central — How Google interprets the robots.txt specification, Google Search Central — List of Google's common crawlers and user agents, Google Crawling Infrastructure — How the Google-Extended Product Token Works, IETF RFC 9309 — Robots Exclusion Protocol, OpenAI Platform Docs — Overview of OpenAI Crawlers, SearchBop — Robots.txt Tester

Related workflows

Explore the relevant Searchbop workflow or use a free browser tool.