Guide · Crawling

Robots.txt mistakes that block useful pages

Robots.txt is a plain text file at the root of a site. It gives cooperative crawlers instructions about which paths they may request. It is not a password wall, and it is not a reliable way to remove a private file from the internet.

Most robots.txt problems are not exotic. A site blocks a folder for staging, forgets to remove the rule, and later publishes the public pages inside that folder. Or a template adds Disallow: / and the whole site disappears from crawling. This guide shows the common mistakes and a test you can repeat.

How a group works

A group starts with one or more User-agent lines. The Allow and Disallow lines that follow apply to that group. A Sitemap line is a global pointer to an XML sitemap, not a rule inside the group.

User-agent: * Disallow: /private/ Allow: /private/public/ Sitemap: https://example.com/sitemap.xml

The example asks all crawlers not to request /private/, but permits the public subsection /private/public/. The sitemap line tells crawlers where the XML sitemap is.

Five mistakes that block useful pages

1. Disallow: / on a public site

Disallow: / blocks the whole site for the selected group. It is sometimes copied from a staging template and left in production. The result is a site that crawlers are asked not to request at all.

# Wrong for a public site User-agent: * Disallow: / # A narrower rule User-agent: * Disallow: /private/

2. Blocking CSS or JavaScript

If a crawler cannot fetch the CSS or JavaScript that shapes the page, it may see a different page than a visitor. Google's documentation asks site owners to check whether blocking these resources prevents the crawler from rendering the page correctly. Blocking a whole asset directory to "save crawl budget" is usually a bad trade.

3. Empty Disallow

An empty Disallow: does not block anything. It is often left behind after a path is removed. It adds noise, and it can hide the fact that a real rule was deleted.

# Noise Disallow: # A real rule Disallow: /private/

4. Duplicate or contradictory rules

Two identical rules are harmless to many crawlers but make the file hard to audit. A Allow: / next to a Disallow: / is worse: the file says two opposite things, and the reader has to know which rule wins.

5. Treating robots.txt as access control

A disallowed URL can still be linked, discovered, requested directly or seen by a crawler that ignores the file. If a file must be private, use authentication, a signed URL or server permissions. Robots.txt only guides cooperative crawlers.

Allow, Disallow and the longest match

The common matching model is: choose the most specific group for the crawler, find the longest matching rule, and let Allow win a tie against a Disallow of the same length. Wildcards * and the end anchor $ are supported by major crawlers, but implementations can differ.

RulesPathTypical result
Disallow: /private/
Allow: /private/public/
/private/public/pageAllowed, because the Allow rule is longer
Same rules/private/draftBlocked by the Disallow
Disallow: /*.pdf$/guide.pdfBlocked by the anchored wildcard
No matching rule/aboutAllowed by default

Robots.txt, noindex and authentication

These are different tools with different jobs. Mixing them up is a common source of "the page is gone but the URL still appears" reports.

ToolWhat it doesWhat it does not do
robots.txtAsks a cooperative crawler not to request a path.Does not hide a URL from links, browsers or crawlers that ignore the file.
noindexAsks a search engine not to show the page in results.Does not stop a person from opening the page; the crawler must be able to fetch it to see the directive.
AuthenticationRequires a login or another credential.Does not automatically remove an already indexed URL; handle that separately.

If a page should not appear in search results, use noindex and make sure the page is crawlable. If a file must be private, use authentication. If you only want to reduce crawling of a low-value path, robots.txt may be enough.

How to test a robots.txt change

  1. Edit the file locally. Use the builder or a text editor. Keep one intent per group.
  2. Parse the result. Paste it into the inspector. Look for duplicate rules, empty rules, Disallow: / and a relative sitemap URL.
  3. Test the paths that matter. Test the home page, a public article, the asset directory and the private folder. Confirm the longest matching rule.
  4. Deploy and fetch the live file. Open https://your-domain/robots.txt and compare it with the local copy. A CDN or host panel can serve a different file.
  5. Check the crawler documentation. If a rule depends on wildcards or group selection, read the specific crawler's documentation. The model is not a promise.

What the tool cannot tell you

  • How every crawler implements wildcards, group selection or redirects.
  • Whether a crawler will honor the file at all.
  • Whether a URL has been discovered through a link, a sitemap or another source.
  • The live response, server status or a WAF rule.
  • Whether the page is indexed. Robots.txt controls crawling, not indexing directly.

Sources

Written and tested by Mark. The rules in this guide were exercised in the robots.txt inspector and the Test Lab. The tool models common longest-match behavior; it does not claim to reproduce every crawler.

Found an error? Use the corrections page. Last updated 2026-11-23.