robots.txt: Crawling Rules, Examples and Common Errors

Internet

SEO discussions often concentrate on content, links and technical optimisation. All of that work also depends on search crawlers being able to retrieve the right resources without unnecessary obstruction. One of the basic controls involved is a small public file: robots.txt.

The file communicates crawling rules to compliant automated clients. Its usefulness comes with important limits. It is not a firewall, it does not protect confidential information and it should not be confused with an instruction preventing indexing.

This guide explains the file's structure, common configurations, risks and testing practices. Examples are illustrative and should be adapted to the actual application rather than copied into a live site without checking their effects.

 

What Is robots.txt?

robots.txt is a plain-text file served at the root of the relevant origin. A typical address is:

https://example.com/robots.txt

It uses the Robots Exclusion Protocol to state which paths particular crawlers may or may not retrieve. The protocol is documented in RFC 9309, with additional details depending on the crawler's implementation.

These are requests to participating clients, not enforced access restrictions. A malicious or noncompliant bot can ignore them. Anything requiring privacy needs actual access control.

 

Why It Matters

Managing Unnecessary Crawling

On large sites, avoiding unneeded URL spaces can reduce wasted requests and server work. That may help resources be used more efficiently, especially where combinations of parameters create a very large set of similar URLs.

It does not force a search engine to redirect all saved requests towards preferred articles or guarantee faster indexing. Crawl demand and capacity still determine what the engine chooses to retrieve.

Duplicated and Low-Value URL Spaces

Filter combinations, sorting parameters and temporary areas may not deserve the same treatment as useful public landing pages. Decide separately whether the goal is to limit crawling, consolidate duplicate representations or exclude a page from the index.

Those goals require different mechanisms. A robots.txt block alone does not ensure that a linked URL disappears from search.

Development Environments

A crawling block may form part of a testing setup, but it does not protect a staging site. Authentication or another suitable access restriction is the appropriate foundation when the environment must remain private.

Check the production configuration before launch so a development restriction is not accidentally carried onto the public site.

 

Basic Terminology

  • User-agent identifies the crawler or group to which rules apply, such as Googlebot or Bingbot.
  • Disallow identifies a path that the matching crawler should not retrieve.
  • Allow identifies an exception or explicitly permitted matching path in implementations supporting it.
  • Sitemap provides the location of a sitemap.
  • Crawl-delay is recognised by some clients but is not supported by Googlebot as a robots.txt directive.

Do not assume every crawler interprets unsupported fields in the same way. Consult the relevant documentation when a rule depends on a particular implementation.

 

How the File Is Used

A compliant crawler retrieves and processes robots.txt for the relevant origin, selects an applicable user-agent group and applies the matching rules. Clients may cache the file, so a change is not necessarily observed instantly by every crawler.

The essential distinction is between blocking retrieval and preventing indexing. A URL blocked from crawling may still be known through links and may appear in search without its full content having been retrieved.

A crawler that cannot retrieve a page also cannot read a noindex instruction on that page. This is why crawling restrictions must not be used as a substitute for indexing controls.

 

The Basic Structure

Consider this example:

User-agent: *
Disallow: /admin/
Disallow: /tmp/
Allow: /admin/login
Sitemap: https://example.com/sitemap.xml

The asterisk identifies a general group. The rules block the specified administrative and temporary paths, permit the more specific login path for clients applying these rules, and identify a sitemap location.

This is a syntax example, not a security configuration. Administrative interfaces still require authentication. Rule specificity, path matching and the applicable crawler group matter when interpreting an exception.

 

Common Configurations

Allow Crawling Generally

User-agent: *
Disallow:

An empty Disallow value does not impose a path restriction. Other applicable controls, response conditions and crawler policies can still affect retrieval.

Block the Entire Site

User-agent: *
Disallow: /

This requests that matching compliant crawlers avoid all paths. It can be useful in a controlled temporary setup, but it is dangerous if accidentally published on a site intended for search discovery. It still does not make the site private or reliably remove already known URLs from an index.

Block Particular Directories

User-agent: *
Disallow: /search/
Disallow: /cart/
Disallow: /cgi-bin/

These paths are examples. Check whether the actual application uses them and whether any important resources or public pages would also match.

Limit Selected Parameters

User-agent: *
Disallow: /*?sort=
Disallow: /*&page=

These illustrative patterns do not match every possible parameter order. The second could also block useful pagination, preventing discovery of items that depend on it. Review real URLs before adopting a broad pattern.

Google's former Search Console URL Parameters tool has been retired. Plan parameter behaviour through the application, internal links, appropriate canonical signals and carefully chosen crawling rules. Do not rely on a setting that is no longer available.

Target a Particular Crawler

User-agent: Googlebot-Image
Disallow: /private-images/

This example addresses Google's image crawler for the specified path. It is not a general privacy rule for images and does not apply automatically to every other client.

 

What Not to Do

Do Not Hide Confidential Content with robots.txt

Use authentication and authorisation for information that should not be publicly accessible. If a resource has genuinely been removed, return an appropriate response, such as 404 or 410 where suitable.

A status code is not a replacement for access control when confidential content continues to exist. Publishing its path in robots.txt may reveal an otherwise obscure location to anyone reading the file.

Do Not Substitute It for noindex

A page-level indexing instruction can be expressed, for example, as:

<meta name="robots" content="noindex">

An appropriate X-Robots-Tag HTTP response header can provide a related mechanism. The intended crawler needs access to retrieve and process the instruction. Google does not support placing a noindex directive in robots.txt.

Avoid Unexamined Rule Complexity

Long sets of overlapping Allow and Disallow patterns are difficult to maintain. The problem is not that every overlap is invalid: clients have matching rules. The risk is that a publisher misunderstands which group or path takes precedence.

Keep the configuration understandable and test representative allowed and blocked URLs.

 

The Relationship with SEO

A well-planned file can improve crawling efficiency by avoiding unnecessary URL spaces and preserving access to useful content and resources. It does not independently create stronger content architecture or guarantee removal of low-value pages from results.

A mistaken block can prevent a crawler from obtaining essential pages or resources. That can disrupt rendering, discovery and the processing of indexing signals, with consequences for search visibility.

The practical objective is controlled retrieval aligned with the site's publishing purpose. Indexing, canonicalisation and access restrictions need their own consistent decisions.

 

Common Mistakes

Serving the File in the Wrong Place

For the origin in this example, the intended location is:

https://example.com/robots.txt

A file at the following address does not act as that origin's root robots.txt:

https://example.com/blog/robots.txt

Check the exact scheme, host and port involved. Different origins can require different configurations.

Blocking Resources Needed for Rendering

Some stylesheets, scripts and other resources help a crawler understand the page. Blocking all CSS or JavaScript indiscriminately can make the rendered experience incomplete.

Inspect what the actual template needs instead of assuming that every technical directory should be excluded.

Carrying a Development Block into Production

A forgotten Disallow: / rule can obstruct a public launch. It is a simple line with extensive consequences for compliant crawling, even though it does not erase the website from every index immediately.

Include robots.txt in deployment and migration checks, alongside authentication, status codes and indexing instructions.

 

Further Considerations for Large Sites

Use server logs to understand which clients retrieve which URL patterns and how often. Verify crawler identities where needed rather than trusting only a user-agent label.

Different subdomains or origins can need separate robots.txt files. Dynamic filtering also requires a coherent strategy: canonical annotations, noindex and crawling rules have different roles and should not be combined blindly on the same URLs.

During migrations, confirm that both the old and new environments expose the resources necessary for the intended transition. A correct redirect can be of little use to a client prevented from requesting it.

 

Testing Changes

Inspect the publicly served file and its response. When the file is intended to exist normally, a successful text response is expected; error responses have crawler-specific consequences and should not be treated casually.

Use current Search Console robots.txt reporting and suitable inspection or testing tools. The old robots.txt Tester and Fetch as Google interfaces should not be assumed to remain available under their former names.

After a change:

  • Check the actual response, encoding and content.
  • Test representative URLs against the applicable user-agent rules.
  • Review useful pages and rendering resources for accidental blocks.
  • Check relevant logs or subsequent crawler reporting when available.

A live URL inspection concerns a particular resource and does not replace a review of the full configuration. Remember that cached copies can delay observation of a change.

 

Security Misconceptions

Listing a sensitive directory makes the path public. Humans can read the file, and noncompliant bots may ignore its instructions entirely.

Privacy depends on access control and authorisation. The distinction remains important even when a crawler appears to respect a block. A respectful client's behaviour is not a security boundary.

 

An Illustrative WordPress-Oriented Configuration

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /search/
Disallow: /cart/
Disallow: /*?sessionid=
Sitemap: https://example.com/sitemap.xml
Sitemap: https://example.com/news-sitemap.xml

This example limits several selected paths, retains access to an administrative AJAX endpoint used by some public interfaces and lists two sitemaps. It is not a universal “healthy” configuration for every WordPress installation.

The paths must match the actual website. Only include a news sitemap if a valid, relevant one exists. Check parameter order, useful search or cart functionality and resources required by the public page before applying any rule.

 

A Small File Requiring Deliberate Decisions

robots.txt is a useful point of control in a search-access strategy. Used carefully, it can prevent unnecessary crawling and make technical intentions easier to maintain. Used carelessly, it can obstruct the very material a publisher wants discovered.

The strongest approach is a simple, consistent, tested and documented configuration. Keep crawling controls distinct from indexing instructions and security, and review the file whenever a deployment, migration or change in URL behaviour could alter what its rules affect.

 

References

🗓️ Publication date: November 10, 2026
🔄 Last updated: November 10, 2026
🎯 Who this is for: Webmasters, developers, SEO practitioners and site owners who need a practical understanding of robots.txt syntax, crawling and indexing distinctions, security limitations and configuration testing.

Content information
This article contains approximately 1955 words and 13413 characters. Estimated reading time: 7 min. It was prepared in accordance with Invictus Wiki's editorial principles and published on the basis of reliable, verifiable sources. The information is reviewed regularly to keep it up to date.
Would you like to share this article?