# X-Robots-Tag HTTP Header: A Practical SEO Guide

> When to use the X-Robots-Tag HTTP header over the robots meta tag: noindex and unavailable_after syntax, Netlify, Apache and Nginx examples, and verification.

Source: https://ranklocaltoday.com/blog/x-robots-tag-http-header-guide  
Last updated: 2026-10-07

Technical SEO

# The X-Robots-Tag HTTP Header: When to Use It, How to Set It, and How to Verify It

Control indexing for PDFs, images, and whole directories at the server level, and avoid the robots.txt mistake that hides your header.

By **RankLocalToday** Updated Oct 7, 2026 12 min read

For: Local service business owners, marketers, and developers managing indexing for PDFs, images, and bulk URL patterns

**Any file type** PDFs, images, and documents can carry indexing rules

**One rule, many URLs** Server or CDN patterns replace per-page edits

**Crawl required** A robots.txt block hides the header from Google

**Recrawl delay** Changes apply only after the URL is fetched again

Most indexing advice assumes every page is an HTML document with a `<head>` you can edit. Real sites are messier. A plumber's website has a PDF price sheet, a Word-format intake form, a folder of before-and-after photos, a staging copy that never got locked down, and a few hundred auto-generated URLs that were never meant for search. None of those can carry a robots meta tag, and some of them are quietly competing with your real service pages in Google.

The X-Robots-Tag HTTP header solves that. It delivers the same indexing instructions as the robots meta tag, but in the server response instead of the page markup, which means it works on any file type and can be applied to thousands of URLs with a single rule. This guide covers when to use it, the exact syntax and directives, working configurations for Netlify, Apache, and Nginx, the robots.txt mistake that silently defeats it, and how to verify the header is actually being served.

**Best use case:** The header controls indexing, not access, so confidential files still need authentication.

## What the X-Robots-Tag header is and how it differs from the meta tag

Every time a crawler requests a URL, the server answers with a status line, a set of response headers, and then (usually) a body. The X-Robots-Tag is one of those response headers. A minimal example looks like this:

```
HTTP/2 200
content-type: application/pdf
x-robots-tag: noindex
```

When Googlebot fetches that PDF and reads the header, it treats the file the same way it would treat an HTML page containing `<meta name="robots" content="noindex">`. The URL is dropped from the index after it is recrawled and processed. The directives are the same vocabulary; only the delivery channel differs.

That channel difference is the whole point. A meta tag lives inside the HTML document, so it only exists for HTML. A header lives in the HTTP response, so it exists for everything a server can serve: PDFs, images, video, Word and Excel files, JSON, plain-text files, and generated downloads. Google documents X-Robots-Tag support as a standard way to control indexing and snippet behavior for non-HTML resources.

The two methods are not rivals, and they can coexist. If a page carries both a meta robots tag and an X-Robots-Tag header, crawlers combine them, and when directives conflict the more restrictive one wins. In practice, that means you should avoid contradicting yourself across layers, because the strictest instruction will apply whether or not you intended it.

## When to use the header instead of the robots meta tag

For a normal HTML page you control in a CMS, the meta tag is simpler, easier to audit, and visible in page source to anyone on your team. Reach for the header in these situations instead.

**Non-HTML files.** This is the clearest case. If you want a PDF brochure, a Word-format estimate template, or an image kept out of search results, the header is your only in-band option. Local service businesses accumulate these constantly: menus, coupon sheets, service-area PDFs, warranty documents, and downloadable checklists that duplicate content already on a page.

**Bulk control at the server or CDN level.** Suppose 400 filtered or print-friendly URLs share a path pattern. Editing 400 templates is slow and error-prone; one header rule on the pattern is not. The same applies to entire directories such as `/thank-you/`, `/internal/`, or `/downloads/`.

**Staging and preview environments.** Applying `X-Robots-Tag: noindex, nofollow` to everything on a staging hostname is a safety net that does not depend on every developer remembering a meta tag. Pair it with authentication where you can, since a header is a request to crawlers, not a lock.

Stick with the meta tag when you manage individual HTML pages through a CMS and want per-page decisions that editors can see and change. A hybrid is common: header rules for file types and directories, meta tags for individual pages. If you are unsure which of your pages are indexable at all, a [website SEO audit](https://ranklocaltoday.com/website-seo-audit) will surface the current indexing state before you start adding rules.

## Syntax and the directives that matter

The header value is a comma-separated list of directives. You can send multiple directives in one header or in separate header lines; both are valid.

```
X-Robots-Tag: noindex, nofollow
X-Robots-Tag: noarchive
X-Robots-Tag: unavailable_after: 25 Dec 2026 15:00:00 PST
```

The directives you will use most often:

- **noindex** keeps the URL out of search results. For a file, this is the main tool for removing or preventing indexing.
- **nofollow** tells crawlers not to follow links found in the resource. It is mostly relevant to HTML, though PDFs can contain links too.
- **none** is shorthand for `noindex, nofollow`.
- **noarchive** asks search engines not to show a cached copy link. Google has retired its public cache links, so this matters less in Google today, but other engines may still honor it.
- **nosnippet** prevents text snippets and video previews in results. Use it carefully, because it can also reduce how your content is used in rich results and AI-generated summaries.
- **noimageindex** keeps images on that page out of image search. For image files themselves, use `noindex`.
- **max-snippet, max-image-preview, max-video-preview** cap how much of the content can appear in results, for example `max-snippet:160` or `max-image-preview:large`.
- **unavailable_after** sets a date after which the page should no longer appear in results.

**Targeting a specific crawler.** Prefix the directive with a user agent token and a colon:

```
X-Robots-Tag: googlebot: noindex
X-Robots-Tag: bingbot: noarchive, nofollow
```

A header with no user agent applies to all crawlers that honor it. If you send both a general header and a bot-specific one, the bot-specific rule is added to the general one for that crawler, and again the more restrictive combination applies.

**How unavailable_after behaves.** This directive is built for time-limited content: a seasonal promotion, a limited-time coupon PDF, an event page. Google accepts widely used date formats including RFC 822, RFC 850, and ISO 8601. The date is not a delete button. Once the date passes, the URL becomes eligible for removal, but removal still depends on Google recrawling the URL and processing the instruction, so expect a lag. Treat it as cleanup automation, not a guaranteed expiry. Always include a timezone, because ambiguity will make you wonder why a page lingered.

## Setting the header on Netlify with a _headers file

Netlify lets you add custom headers either in a plain-text `_headers` file placed in your publish directory or in `netlify.toml`. The `_headers` format is a path on one line, followed by indented header lines.

```
# /_headers

# Keep an entire directory of downloads out of the index
/downloads/*
X-Robots-Tag: noindex, nofollow

# Internal documents and thank-you pages
/internal/*
X-Robots-Tag: none

/thank-you/*
X-Robots-Tag: noindex

# Expire a seasonal promo PDF
/promos/fall-tune-up.pdf
X-Robots-Tag: unavailable_after: 30 Nov 2026 23:59:00 EST
```

The same rule expressed in `netlify.toml`:

```
[[headers]]
for = "/downloads/*"
[headers.values]
X-Robots-Tag = "noindex, nofollow"
```

Two practical notes. First, Netlify applies every matching rule, and when several rules match one URL, header values for the same name can be combined, so avoid writing overlapping rules that send contradictory directives. Second, wildcard behavior is the part most worth testing rather than assuming. Directory splats like `/downloads/*` are the safest pattern. If you want to target by extension across the whole site, deploy to a preview URL and confirm with a request that the header appears on the files you meant and does not appear on pages you did not. Preview deploys are also where you should confirm that production-only rules are not leaking into staging, and vice versa.

## Apache, Nginx, and CDN examples

Netlify is common for static sites, but plenty of local business sites run on shared hosting or a VPS. The configuration is short in either case.

**Apache** uses `mod_headers`, which must be enabled. Put this in the main config or `.htaccess`:

```
# Noindex all PDFs and Office documents
<FilesMatch "\.(pdf|docx?|xlsx?|pptx?)$">
Header set X-Robots-Tag "noindex, nofollow"
</FilesMatch>

# Noindex an entire directory
<Location "/internal/">
Header set X-Robots-Tag "noindex, nofollow"
</Location>
```

Use `Header set` to replace any existing value or `Header append` to add to it. Inside `.htaccess`, the `Location` block is not available, so use a `FilesMatch` or place a small `.htaccess` file inside the directory you want covered.

**Nginx** uses `add_header` inside a location, server, or http block:

```
location ~* \.(pdf|docx?|xlsx?)$ {
add_header X-Robots-Tag "noindex, nofollow" always;
}

location /internal/ {
add_header X-Robots-Tag "noindex, nofollow" always;
}
```

Include `always` so the header is also sent on non-200 responses. Be aware of Nginx's inheritance rule: if a location block defines any `add_header` directive of its own, it stops inheriting `add_header` lines from the parent server block. A header you set globally can disappear from one location because someone added an unrelated header there. This is a frequent cause of "it works on most URLs but not that folder."

**CDNs and edge platforms.** Cloudflare, Fastly, CloudFront, and similar services let you attach response headers by path rule, often without touching the origin server. That is convenient for bulk control, but it also creates a second place headers can be set, which is a classic source of confusion. Document where each rule lives. If you set X-Robots-Tag at both origin and edge, test the final response a crawler sees, not either layer in isolation.

## The robots.txt mistake that makes the header invisible

This is the most common and most damaging error with X-Robots-Tag, and it follows directly from how crawling works. A header can only be read if the crawler requests the URL. If robots.txt disallows the URL, Googlebot never fetches it, never sees the response headers, and never learns that you asked for noindex.

Here is how it plays out. You decide a folder of PDFs should not be in search results. You add a header rule setting `noindex` for the folder, and, wanting to be thorough, you also add this to robots.txt:

```
User-agent: *
Disallow: /downloads/
```

It feels like double protection. It is the opposite. Because the path is disallowed, the crawler never reaches the file to read the noindex. If other sites or your own pages link to those PDFs, Google can still index the bare URL, typically showing it without a description. Blocking crawling and blocking indexing are different things, and the two controls interfere with each other when stacked.

The correct approach depends on your goal:

- **To keep files out of the index:** allow crawling in robots.txt and serve `noindex` in the header. Let the crawler in so it can read the instruction.
- **To save crawl budget on genuinely worthless URLs:** a robots.txt disallow is reasonable, but understand it does not guarantee de-indexing and does not communicate noindex.
- **To remove something already indexed:** unblock it in robots.txt, add the header, wait for recrawl, and only consider re-blocking after the URL has dropped out. For urgent cases, the removals tool in Search Console can hide a URL temporarily while the header does its work.

Also note that a `noindex` line inside robots.txt itself is not supported by Google, so do not try to put the directive there. Indexing instructions travel in the meta tag or the header, and robots.txt controls fetching. Keeping that division clear prevents most of the mistakes in this article.

## Other common mistakes to avoid

**Shipping a staging rule to production.** A site-wide `X-Robots-Tag: noindex` is a perfectly reasonable staging safeguard. If it rides along in a deploy to the live site, your entire site starts dropping out of search over the following weeks. Keep environment-specific rules in environment-specific configuration, and add a post-deploy check on your homepage and top service pages. This is the header version of the old "noindex left on after launch" disaster, and because headers are invisible in page source, it can go unnoticed far longer.

**Patterns that match too much.** A regex or wildcard intended for `/downloads/` that also catches `/downloads-and-guides/` or a service page slug will noindex pages you want ranking. Test patterns against a list of real URLs, and keep rules narrow.

**Forgetting redirects and canonicals.** A header applies to the URL that returns it. If a PDF redirects, the header on the destination is what counts. Also avoid sending noindex on a page that other pages canonicalize to; mixed signals make outcomes unpredictable.

**Expecting instant results.** Header changes take effect when the URL is recrawled. Files that are rarely crawled can take weeks to drop. Plan for that rather than assuming the rule failed.

**Treating the header as security.** X-Robots-Tag is a polite instruction to well-behaved crawlers. Confidential documents need authentication, not a header. If a quote form with customer details is reachable by URL, protect it properly.

## How to verify the header is being served

Never assume a configuration change worked. Confirm what the server actually returns, using several methods.

**curl from the command line.** The fastest check is requesting only the headers:

```
curl -sI https://www.example.com/downloads/price-sheet.pdf

HTTP/2 200
content-type: application/pdf
x-robots-tag: noindex, nofollow
```

Add `-L` to follow redirects and see the final response, and set a crawler user agent to test conditional rules:

```
curl -sIL -A "Googlebot" https://www.example.com/downloads/price-sheet.pdf
```

Run the same check on a page that must stay indexable, such as your homepage. The absence of an `x-robots-tag` line there is exactly what you want to see. Some servers answer HEAD requests differently from GET, so if results look odd, confirm with `curl -s -D - -o /dev/null URL`, which performs a real GET and prints headers.

**Browser DevTools.** Open the Network tab, load the file or page, click the request, and read the Response Headers panel. This is helpful for HTML pages and for seeing what a CDN actually returns.

**Google Search Console.** The URL Inspection tool reports whether indexing is allowed and, when a header is responsible, names it. A live test shows what Googlebot sees right now, which is the authoritative confirmation. If Search Console says the URL is blocked by robots.txt, you have found the problem from the previous section.

**Crawlers and audits.** Site crawlers can extract X-Robots-Tag values across thousands of URLs at once, which is the efficient way to catch an overly broad rule. Export the list of noindexed URLs and compare it against your money pages: service pages, location pages, and your top blog posts should never appear on it. For a structured pass, run a [website SEO audit](https://ranklocaltoday.com/website-seo-audit) and review the indexability findings alongside the header list.

Build a short routine around it. After any server, CDN, or deploy change, spot-check five URLs: one PDF that should be noindexed, one image, your homepage, one key service page, and one blog post. It takes two minutes and protects against the costly failures. Once the plumbing is right, focus on content that earns citations in AI answers, which our [blog](https://ranklocaltoday.com/blog) covers in depth.

## FAQ

### Is X-Robots-Tag better than the robots meta tag?

Neither is universally better. The header is the right choice for non-HTML files like PDFs and images, and for applying one rule to many URLs at the server or CDN level. The meta tag is simpler for individual HTML pages managed in a CMS. Many sites use both, and crawlers apply the most restrictive combined instruction.

### Why is my noindex header not working?

The most common cause is a robots.txt disallow on the same URL, which stops Googlebot from fetching the file and reading the header. Other causes include a CDN stripping or overriding headers, a pattern that does not match the URL, and simply waiting for a recrawl. Check the live response with curl and Search Console's URL Inspection.

### Does unavailable_after remove a page immediately on that date?

No. The date makes the URL eligible for removal, but Google still has to recrawl it and process the instruction, so a delay is normal. Include a timezone in the date and treat it as scheduled cleanup rather than an exact deletion. For urgent removals, use the Search Console removals tool alongside it.

### Can I put X-Robots-Tag on images and PDFs?

Yes, that is its main advantage. Configure the header by file extension or directory, such as all PDFs or everything under a downloads folder, and send noindex. Since these files have no head section for a meta tag, the HTTP header is the standard way to control their indexing.

### How do I check that the header is live?

Run curl -sI against the URL and look for an x-robots-tag line, or open the browser DevTools Network tab and read the response headers. Then use Search Console's URL Inspection live test to confirm what Googlebot sees. Also confirm that important pages do not return the header.

### Turn this into a practical SEO action plan

Use RankLocalToday tools to check rankings, diagnose website issues, and prioritize the next organic traffic move.

[Get your SEO plan →](https://ranklocaltoday.com/local-seo-plan)

More in this topic: [Website SEO, all 208 guides →](https://ranklocaltoday.com/blog/local-website-seo-guides)
