Robots Exclusion Protocol
Definition
A robots.txt file is a plain text document positioned at the root directory of a domain that instructs search engine web crawlers which URLs and directories they are permitted or forbidden to request.
Why It Matters
robots.txt prevents web scrapers and crawlers from overwhelming internal server resources with unnecessary requests to administrative endpoints, internal search queries, or staging environments. However, blocking a page in robots.txt does NOT prevent it from being indexed if external backlinks point to it; only noindex meta tags prevent indexing.
Robots.txt Standard Syntax Directives (RFC 9309)
| Criterion / State | Requirement / Target | Status |
|---|---|---|
| File Location | Root domain only: https://domain.com/robots.txt | Optimal |
| HTTP Status | Must return HTTP 200 OK with text/plain content type | Optimal |
| User-agent | Specifies crawler token (* for all, Googlebot, etc.) | Standard |
| Sitemap Line | Include absolute XML sitemap URL directive | Optimal |
Practical Implementation Example
Next.js MetadataRoute generates a valid, dynamic robots.txt file blocking private application routes while advertising the sitemap location to all search engines.
import type { MetadataRoute } from 'next';
export default function robots(): MetadataRoute.Robots {
return {
rules: [
{
userAgent: '*',
allow: '/',
disallow: ['/api/', '/dashboard/', '/admin/'],
},
],
sitemap: 'https://example.com/sitemap.xml',
};
}How to Audit robots.txt in ScanWise
ScanWise audits your robots.txt syntax against the RFC 9309 standard, alerting you to unintentional disallow rules that block Googlebot from indexing key revenue routes.
Audit your robots.txt syntax and crawler directives in ScanWiseCommon robots.txt Mistakes & How to Fix Them
| Mistake | Why It Hurts | The Fix |
|---|---|---|
| Using Disallow: / in production or forgetting to remove staging block rules after launching. | A single Disallow: / line completely instructs all compliant search engines to halt crawling the entire domain. | Environment-gate robots rules so Disallow: / is strictly confined to preview and staging hostnames. |
| Attempting to use Noindex: directives inside robots.txt. | Google officially removed support for noindex in robots.txt in September 2019; it is completely ignored. | Serve <meta name='robots' content='noindex'> HTML tags or X-Robots-Tag: noindex HTTP response headers. |
Related Engineering Guides
Robots.txt Configuration for Next.js Applications: Syntax & Pitfalls
Set up dynamic robots.txt in Next.js App Router, prevent indexing leaks, and avoid staging crawler traps.
XML Sitemap Guide for Next.js: Dynamic Generation & Indexing
Connect your XML sitemaps to robots.txt to guide search engine discovery pipelines.
Technical SEO Pre-Launch Checklist: 25 Non-Negotiable Checks
Verify crawler directives and staging protection rules prior to production domain rollout.