# Check robots.txt access and syntax

- Check 03.01 · Crawling · Critical
- Source: https://checklist-seo-geo.com/en/crawling/check-robotstxt-access-syntax
- Make sure robots.txt returns 200 as plain text on every host with no syntax errors, then fix it on Apache, Nginx, Cloudflare, WordPress or Next.js.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/crawling/check-robotstxt-access-syntax.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

The robots.txt file is the first URL a crawler requests before exploring a site. This check covers two things: that the file is reachable (status 200, plain text, no detour and no anti-bot challenge) on every host and every protocol, and that its content follows the syntax Google, Bing and AI crawlers can read. Once it is done, `https://example.com/robots.txt` returns `200 text/plain`, every line is valid, and no rule blocks part of the site by mistake.

## Why it matters

A crawler does not read your file the way you do: it applies strict rules, documented by Google and standardized in RFC 9309 (Robots Exclusion Protocol). The HTTP status returned for `/robots.txt` matters as much as its content:

| Response to `/robots.txt` | What Google does |
| --- | --- |
| `200` | applies the rules in the file |
| `3xx` | follows up to five redirects, then treats the file as missing |
| `4xx` (except `429`), including `401`, `403` and `404` | assumes there are no restrictions: the whole site can be crawled |
| `5xx`, timeout, DNS error | stops crawling the site for 12 hours, then relies on the last known version for up to 30 days |

The last row is the most dangerous: a robots.txt that returns a server error halts crawling of the whole site, even if the pages themselves work. The opposite case is sneakier: a single-page application that returns its HTML home page, with a `200`, in place of a missing file. Google tries to extract valid rules from it and ignores the rest; the result is not what you think.

The content follows precise rules too:

- **Encoding**: plain text, UTF-8. Non-UTF-8 characters can invalidate a rule; a byte order mark (BOM) at the start of the file is ignored by Google, but can make less tolerant parsers fail to read the first line.
- **Size**: Google ignores everything beyond 500 KiB.
- **Scope**: the file applies to one host, one protocol and one port. `https://example.com/robots.txt` says nothing about `https://www.example.com/` or `http://example.com/`.
- **Fields Google recognizes**: `user-agent`, `allow`, `disallow`, `sitemap`. Everything else (`crawl-delay`, `noindex`, `host`) is ignored by Google; Bing reads `crawl-delay`.
- **Caching**: Google generally keeps the file for up to 24 hours. A fix is therefore not visible right away.

Generative engine crawlers (OAI-SearchBot, PerplexityBot, Claude-SearchBot) read the same file. An unreachable or malformed robots.txt therefore disrupts both classic search and your [AI crawler policy](https://checklist-seo-geo.com/en/ai-crawler-access-data-policy/configure-robotstxt-match-these-goals).

## What it improves

- **Crawling**: no more crawl suspension caused by a failing file, no more rule blocking a section by accident.
- **Indexing**: strategic pages stay crawlable, and the sections you want to keep out really are.
- **Generative engines**: AI crawlers apply the policy you wrote, not a truncated or misread version. This does not guarantee any citation.
- **Diagnostics**: a clean, commented file makes the Search Console and Bing Webmaster Tools reports readable.
- **Rankings**: no direct effect. robots.txt governs access, not position.

## How to check

**1. Status, type and redirects.** Test every host and protocol variant:

```bash
for origine in https://example.com https://www.example.com http://example.com http://www.example.com; do
  curl -s -o /dev/null -L --max-redirs 5 \
    -w "%{http_code} %{content_type} %{num_redirects} redir. -> %{url_effective}  ($origine)\n" \
    "$origine/robots.txt"
done
```

Expected result: `200 text/plain` at the end, with at most one or two redirects for the non-canonical variants.

**2. What is actually served.** The file must not start with `<!DOCTYPE` or `<html`, nor contain a challenge page:

```bash
curl -s https://example.com/robots.txt | head -n 20
curl -s https://example.com/robots.txt | wc -c
curl -s https://example.com/robots.txt | head -c 3 | od -An -tx1
```

The second command gives the size in bytes (under 512,000). If the third one prints `ef bb bf`, the file starts with a BOM: save it again as UTF-8 without BOM.

**3. Suspicious lines.** This command lists the lines that are neither empty, nor comments, nor a known field:

```bash
curl -s https://example.com/robots.txt | tr -d '\r' \
  | grep -n -v -i -E '^[[:space:]]*(#.*)?$|^[[:space:]]*(user-agent|allow|disallow|sitemap|crawl-delay|content-signal)[[:space:]]*:'
```

No output is the expected result. A typo (`Dissalow:`), a missing colon or a made-up directive shows up here.

**4. What search engines see.**

- **Google Search Console**: the [robots.txt report](https://search.google.com/search-console/settings/robots-txt) lists the files found for the property's main hosts, their fetch status (“Fetched”, “Not Fetched”), the date of the last check and any parsing issues. It is only available for a Domain property or a URL-prefix property without a path.
- **Bing Webmaster Tools**: the [robots.txt Tester](https://www.bing.com/webmasters/robotstxttester) shows the file for the `http` and `https` variants, with and without `www`, and tests a URL the way Bingbot would.

## How to implement

### Before you start

Syntax reminder, valid for every environment:

| Element | Rule |
| --- | --- |
| Name and location | `robots.txt`, lowercase, at the root of the host. A file in a subfolder is ignored. |
| Line | `field: value`. The field name is case-insensitive; the path is case-sensitive. |
| Group | one or more consecutive `User-agent` lines, followed by their rules. A crawler applies only one group: the one that names it, otherwise `*`. |
| Path | starts with `/`. `*` matches any sequence of characters; `$` marks the end of the URL. |
| Conflict | the longest rule wins; for equal length, Google picks `Allow`. |
| `Sitemap` | absolute URL, outside any group, as many lines as needed. |
| Comment | `#` to the end of the line. |

Reference file, to adapt:

```txt
# robots.txt for example.com — last reviewed: 2026-11-25
User-agent: *
Disallow: /admin/
Disallow: /compte/
Disallow: /panier/
Disallow: /recherche?

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

Three robustness principles:

- **Serve a static file** whenever possible: it depends on neither the database nor the application, and does not fall into `5xx` with them.
- **Exempt `/robots.txt`** from any authentication, rate limiting, language redirect and anti-bot challenge.
- **Never return `401`, `403` or `5xx`** for this file. If there is nothing to disallow, a file containing only `User-agent: *` and an empty `Disallow:` line, or a plain `404`, both mean “everything is allowed”.

> **Warning:** do not use a `503` on robots.txt to “slow down” Google. Crawling of the whole site stops. To reduce load, see [optimize crawl budget if warranted](https://checklist-seo-geo.com/en/crawling/optimize-crawl-budget-if-warranted).

### Apache

Versions: Apache 2.4.

The file goes in the virtual host's `DocumentRoot`, for example `/var/www/example/public/robots.txt`, with read permissions (`chmod 644`). Add this block to the virtual host or to `.htaccess` to guarantee the type and access, even if the rest of the site is protected:

```apache
<Files "robots.txt">
    ForceType "text/plain; charset=utf-8"
    Require all granted
</Files>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^robots\.txt$ - [L]
</IfModule>
```

The rewrite rule, placed before the front controller's rules, stops the application from answering in place of the file. `.htaccess` takes effect immediately; for the virtual host, run `sudo apachectl configtest && sudo systemctl reload apache2`.

### Nginx

Versions: Nginx 1.18 and later.

In the `server` block of `/etc/nginx/sites-available/example.conf`:

```nginx
location = /robots.txt {
    root /var/www/example/public;
    default_type "text/plain; charset=utf-8";
    try_files $uri =404;
    auth_basic off;
    allow all;
    access_log off;
}
```

An exact `location` (`=`) takes precedence over rewrite and proxy blocks. If a `limit_req` limit is declared at `server` level, this block does not inherit it unless you repeat it there. Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### LiteSpeed

Versions: LiteSpeed Web Server 6 (Enterprise) and OpenLiteSpeed 1.8; LiteSpeed Cache 6 and 7.

LiteSpeed Web Server reads `.htaccess`: the block from the Apache section applies as is. OpenLiteSpeed only reads its rewrite rules: the `<Files>` block is ignored there, so check the returned type with `curl -I`. If you use LiteSpeed Cache, make sure after each purge that `/robots.txt` is still served as `text/plain`.

### IIS

Versions: IIS 10 (Windows Server 2016 to 2025) with the URL Rewrite 2.1 module.

Put `robots.txt` at the root of the site; the `.txt` type is served as `text/plain` by default. If the site uses a rewrite rule to an application, place this rule first in `web.config`:

```xml
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Servir robots.txt" stopProcessing="true">
          <match url="^robots\.txt$" />
          <action type="None" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
```

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Three settings change what crawlers receive:

- **Anti-bot protection**: in the [security events](https://dash.cloudflare.com/?to=/:account/:zone/security/analytics) log, filter on the path `/robots.txt`. A `Managed Challenge` or `Block` on this URL replaces the file with an HTML page. In [`Security > Security rules`](https://dash.cloudflare.com/?to=/:account/:zone/security/security-rules), create an exception rule with the expression `(http.request.uri.path eq "/robots.txt")` and the `Skip` action. The Free plan's Bot Fight Mode cannot be bypassed this way: turn it off if it challenges crawlers.
- **“I'm Under Attack” mode**: it challenges every request. Do not leave it on longer than the incident.
- **Managed robots.txt**: when enabled, Cloudflare prepends a block to your file. Always reread the public URL, not the origin file.

After a change at the origin, purge the URL in [`Caching > Configuration > Custom Purge`](https://dash.cloudflare.com/?to=/:account/:zone/caching/configuration).

### AWS

Versions: S3, CloudFront and Amplify Hosting, with AWS CLI v2, November 2026.

On a static **S3** site behind **CloudFront**, upload the file with its type, then invalidate:

```bash
aws s3 cp robots.txt s3://BUCKET_NAME/robots.txt --content-type "text/plain; charset=utf-8"
aws cloudfront create-invalidation --distribution-id DISTRIBUTION_ID --paths "/robots.txt"
```

A classic single-page application trap: a CloudFront custom error response that turns `403` and `404` into `/index.html` with a `200` status. If the file is missing, crawlers then receive your home page. Make sure `robots.txt` really exists in the bucket. Run the same check on **Amplify Hosting**, whose rewrite rule to `index.html` has the same effect.

### Plesk

Versions: Plesk Obsidian 18.0.

`Websites & Domains > your domain > Files`, `httpdocs` folder. If password protection (“Password-Protected Directories”) is active on the site (staging), it also applies to the file, which then returns `401`: Google assumes there are no restrictions. This has no consequence as long as the whole site is protected, and it is the right way to [protect a staging site](https://checklist-seo-geo.com/en/indexing-canonicalization/protect-staging-private-data-authentication).

### cPanel

Versions: cPanel & WHM 110 and later (Jupiter theme).

`Files > File Manager`, `public_html` folder or the root of the addon domain. Right-click `robots.txt`, then `Edit`, and choose the `utf-8` encoding when opening it. Check the permissions (`0644`) with `Permissions`.

### Shared hosting

Upload the file over SFTP to the web root (`www/` at OVHcloud, `public_html/` at most other hosts). The `.htaccess` block from the Apache section works. If the test in “How to check” returns a `403` or a verification page while your `.htaccess` is neutral, it is the host's anti-bot protection: ask support to exempt `/robots.txt`.

### Vercel

Versions: Vercel platform, all plans, November 2026.

Put `robots.txt` in `public/`. Static files are served before rewrites; however, if the file is missing, a catch-all rewrite to `index.html` returns the home page with a `200`. Always keep a file in place.

### Netlify

Versions: Netlify platform, all plans, November 2026.

Put the file in the publish directory. A `/* /index.html 200` rule in `_redirects` does not apply to a file that exists, unless it is forced with `200!`: do not use the forced form.

### WordPress

Versions: WordPress 6.0 to 7.1.

Without a physical file, WordPress generates a virtual robots.txt served as `text/plain`. A `robots.txt` file placed at the root replaces it entirely. Check:

- **Who writes the file**: SEO plugin, security plugin, managed host. One source at a time.
- **The visibility checkbox**: since WordPress 5.3, “Discourage search engines from indexing this site” (`Settings > Reading`) adds a `noindex` to pages instead of changing robots.txt; it also disables the native sitemap.
- **Caching**: a page caching plugin or a CDN may keep an old version; purge `/robots.txt` after every change.

### Shopify

Versions: Shopify, all plans, November 2026.

Shopify generates the file. If you have customized it through the `robots.txt.liquid` template, a Liquid error can produce an empty or incomplete file: open `/robots.txt` after every save and compare it with the previous version. Delete the template to go back to the default file.

### Laravel

Versions: Laravel 10 to 13.

Laravel serves `public/robots.txt` as a static file, without going through the application: this is the most robust option. If you generate it through a route, return the right type:

```php
<?php

// routes/web.php
use Illuminate\Support\Facades\Route;

Route::get('/robots.txt', function () {
    $content = view('robots')->render();

    return response($content, 200)->header('Content-Type', 'text/plain; charset=UTF-8');
})->name('robots');
```

Then delete `public/robots.txt`, which the web server would serve first. If a middleware in the `web` group redirects to a language or a login page, exclude this route with `withoutMiddleware()`. During a `php artisan down`, a route returns `503` like the rest of the site, whereas `public/robots.txt` is still served by the web server: one more reason to prefer the static file.

### Next.js

Versions: Next.js 15 and 16 (App Router).

`app/robots.ts` generates the file with the right type. The trap comes from a middleware (the `proxy.ts` file since Next.js 16, `middleware.ts` before) that redirects every URL to a language or a login page. Exclude the file from its `matcher`:

```ts
// proxy.ts (middleware.ts before Next.js 16)
export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],
}
```

Then check with `curl` that `/robots.txt` returns `200` with no redirect to `/fr/robots.txt`.

## Common mistakes

- **A robots.txt returning `5xx`** during an outage or an application update: Google stops crawling the whole site.
- **The home page served instead of the file** by a single-page application rewrite: the file “exists”, but it cannot be read.
- **An anti-bot challenge or a `403` on `/robots.txt`**: depending on the status and the crawler, the file is ignored or replaced with HTML.
- **Only one variant fixed**: the `www` or `http` file stays old or missing. Test all four combinations.
- **Made-up directives** (`Noindex:`, `Host:`, `Index:`): Google ignores them silently.
- **A path without a leading `/` or with the wrong case**: `Disallow: admin/` or `Disallow: /Admin/` do not block `/admin/`.
- **An empty `Disallow:` mistaken for a block**: it disallows nothing. `Disallow: /` is what blocks everything.
- **Judging too early**: the file is cached for up to 24 hours at Google, a few hours at Bing.

## Frequently asked questions

### What happens if my site has no robots.txt?

Without a robots.txt, a site remains fully crawlable: Google treats a missing file, which returns 404, as having no restrictions. So it is not a serious error. Creating the file is still useful to keep out sections with no value, such as the admin area or the cart, to declare your sitemaps and to state your policy toward AI crawlers. The real risk is a file that returns a server error.

### Why does a 503 error on robots.txt block the whole site?

A server error does not let Google know what you allow. To be safe, it stops crawling the whole site for the first 12 hours, then uses the last valid version it has cached for up to 30 days. So serve robots.txt as a static file, independent of the application, so that it stays available even when the site goes down.

### How long does Google take to pick up a new robots.txt?

Google generally caches the robots.txt file for up to 24 hours, sometimes longer if the server responds poorly. To speed things up after an important fix, open the robots.txt report in Search Console and request a recrawl of the file from its menu. Bing keeps its directives in memory for a few hours. Behind a CDN, purge the file's URL as well.

### Does robots.txt have to be UTF-8?

Yes, Google expects a plain text file encoded in UTF-8. Characters in another encoding may be dropped when the file is read and invalidate the rule that contains them, which happens with accented paths saved in Latin-1. Save the file as UTF-8 without BOM in a text editor, never in a word processor, and keep it under 500 KiB.

## Resources

- [Google: How Google interprets the robots.txt specification](https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt)
- [Google: Create and submit a robots.txt file](https://developers.google.com/search/docs/crawling-indexing/robots/create-robots-txt)
- [Google: Search Console robots.txt report](https://support.google.com/webmasters/answer/6062598)
- [Google: open source robots.txt parser library](https://github.com/google/robotstxt)
- [RFC 9309: Robots Exclusion Protocol](https://www.rfc-editor.org/rfc/rfc9309.html)
- [Bing: Bing Webmaster Tools robots.txt Tester](https://blogs.bing.com/webmaster/september-2020/Bing-Webmaster-Tools-makes-it-easy-to-edit-and-verify-your-robots-txt)
- [Next.js: robots file convention](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/robots)

Next steps: [Allow Googlebot on strategic pages](https://checklist-seo-geo.com/en/crawling/allow-googlebot-strategic-pages), [Declare sitemaps in robots.txt](https://checklist-seo-geo.com/en/crawling/declare-sitemaps-robotstxt) and [Monitor robots.txt and noindex](https://checklist-seo-geo.com/en/automation-quality-control/monitor-robotstxt-noindex).
