Skip to content

X-Robots-Tag: how to control indexing with HTTP headers

X-Robots-Tag is an HTTP header that applies noindex and other rules to PDFs, images and any non-HTML file. Learn how it differs from meta robots and how to set it.

An envelope separates a response header from the document it carries.Reference

The X-Robots-Tag is a short instruction your website server sends along with a file. It tells search engines things like whether to show that file in search results.

It's an HTTP response header, which is a line of information the server sends with a file, before the file's content, that visitors don't see. The instructions in it are called indexing directives, and two common ones are noindex, which keeps the URL out of search results, and nofollow, which tells the search engine not to follow the links on the page.

They’re similar to a meta tag, but meta tags are written into a web page's HTML code. The header travels outside the HTML, so X-Robots-Tags work on PDFs, images and other files that can't hold a meta tag.

A typical line looks like this:

X-Robots-Tag: noindex

Google documents the header in its robots meta tag specification. Each rule on that page works both as a meta tag in the HTML and as this header.

How the X-Robots-Tag header works

The X-Robots-Tag does the same job as the meta robots tag, and Google says any rule you can put in a robots meta tag can also be sent as an X-Robots-Tag. The difference is where the rule lives. The meta tag sits inside the page's HTML, while the header is added by your web server, application or content delivery network (CDN) when it sends the file.

A crawler is a search engine's bot, such as Googlebot, that visits URLs. It has to fetch the URL to see the header. Google's robots meta tag specification says these settings can be read and followed only if crawlers are allowed to access the URL that carries them.

Google's noindex documentation shows a minimal response when a crawler reads a page. The first line is the server confirming the file loaded, while the X-Robots-Tag line is the instruction:

HTTP/1.1 200 OK
(...)
X-Robots-Tag: noindex
(...)

Google isn't the only engine reading the header. Bing says each robots meta tag it supports can also be sent as an X-Robots-Tag, and Yandex documents the header too. Seznam is the exception, because its help pages say SeznamBot ignores the X-Robots-Tag and always downloads the full URL.

X-Robots-Tag vs the meta robots tag

Both tags carry the same directives to Google, but they differ in where the directive lives and who can change it:

More columns
AspectMeta robots tagX-Robots-Tag header
PlacementInside the HTML document. Google respects it in the <head> and the <body>In the HTTP response headers, outside the document
File typesHTML pages onlyAny response, including PDFs, images, video and other non-HTML files
ScaleSet per page or per templateSet by server or CDN rules that can match file extensions, directories or a whole host with regular expressions
Who usually edits itContent team or CMS settingsDevelopers, server admins or whoever runs the CDN
How you check itView page source or the rendered DOMcurl, browser DevTools or Search Console's URL Inspection

X-Robots-Tag directives and what they do

Google's specification lists every indexing and serving rule it reads. The same list applies to the header and to the meta tag.

Directives Google supports

These are the rules Google documents, written in header form:

More columns
DirectiveHeader syntaxEffect in Google Search
noindexX-Robots-Tag: noindexDon't show this page, media or resource in search results
nofollowX-Robots-Tag: nofollowDon't follow the links on this page
noneX-Robots-Tag: noneEquivalent to noindex, nofollow
nosnippetX-Robots-Tag: nosnippetNo text snippet or video preview. It covers web search, Google Images, Discover, AI Overviews and AI Mode, and keeps the content from being used as a direct input for AI Overviews and AI Mode
noimageindexX-Robots-Tag: noimageindexDon't index images on this page
unavailable_afterX-Robots-Tag: unavailable_after: 25 Jun 2010 15:00:00 PSTStop showing the page after the date. Formats include RFC 822, RFC 850 and ISO 8601. Google ignores the rule if the date can't be parsed
max-snippet:[number]X-Robots-Tag: max-snippet:20Caps the text snippet at that many characters. 0 equals nosnippet, and -1 lets Google choose
max-image-preview:[setting]X-Robots-Tag: max-image-preview:standardAccepts none, standard or large
max-video-preview:[number]X-Robots-Tag: max-video-preview:-1Caps video previews in seconds. 0 allows a static image at most, and -1 means no limit
notranslateX-Robots-Tag: notranslateDon't offer a translation of the result
indexifembeddedX-Robots-Tag: noindex, indexifembeddedLets Google index the content when another page embeds it through an iframe. It only has an effect alongside noindex
noarchiveX-Robots-Tag: noarchiveGoogle now ignores it because the cached link feature no longer exists

Google keeps noarchive, nocache and nositelinkssearchbox in a reference section of historical rules that Google Search ignores. Leaving noarchive in place does no harm, because Google's changelog says other search engines and services may still use it, and Bing still documents it.

How noindex removes a URL from the index

A noindex takes effect only after Googlebot recrawls the URL and extracts the header. Once that happens, Google drops the page from results entirely, even if other websites link to it. If the URL still appears in results, the usual reason is that Google hasn't crawled it since the header went live.

Use URL Inspection's live test to check the current response, then leave the URL crawlable while Google revisits it. Google says it may take months for Googlebot to revisit a page, depending on how important the page is on the web.

The Removals tool in Search Console is faster but temporary. Google's Help page says it blocks a URL from results for about six months. After that, the URL can return unless the page itself carries a noindex, has been removed, or sits behind a password. Use the Removals tool for urgency and the header for permanence.

Combining directives and targeting user agents

You can put several directives in one header as a comma-separated list, as in X-Robots-Tag: noindex, nofollow. Google also accepts multiple X-Robots-Tag lines in the same response.

A header can also name a crawler before its rules. Google's specification gives this sample:

HTTP/1.1 200 OK
Date: Tue, 25 May 2010 21:42:43 GMT
(...)
X-Robots-Tag: googlebot: nofollow
X-Robots-Tag: otherbot: noindex, nofollow
(...)

The same pattern produces X-Robots-Tag: googlebot: noindex when you want only Google's crawler to drop the URL. Rules sent without a user agent apply to every crawler.

When generic and crawler-specific rules stack up, Google adds them together. In its March 2025 robots refresher, Google combined X-Robots-Tag: examplebot: nosnippet with a generic X-Robots-Tag: nofollow. The crawler named ExampleBot ends up with nosnippet, nofollow, because the most restrictive valid directives apply.

When to use the X-Robots-Tag

Reach for the header when the file can't carry a meta tag, or when one rule needs to cover far more URLs than anyone would tag by hand.

Keep PDFs and images out of the index

PDFs are a common case. Printable PDF copies of HTML pages, gated reports and old price sheets all get crawled and can outrank the page you want people to land on. A noindex header on every .pdf response keeps them out of results while the files stay downloadable.

Images work the same way. Google's guide to removing your own images says a noindex X-Robots-Tag on the image responses removes them from results. You must still allow crawling of the image URLs so Googlebot can read the rule.

Match by file extension in the server or CDN config. One rule then covers every current and future file of that type, which is the point of using the header in the first place.

Apply indexing rules across a whole server

Staging and preview environments are the classic server-wide case. A single header rule on the staging host keeps every URL out of the index without touching templates that also ship to production. Cloudflare's Pages documentation uses the same idea, with a _headers file that sends X-Robots-Tag: noindex so preview .pages.dev URLs stay out of search.

Directory rules cover generated files at scale. Think of an exports folder, auto-generated feed files or internal search result pages that a script produces faster than any CMS could tag. Put the rule on the directory or path pattern, and every file the script writes inherits it.

How to set the X-Robots-Tag on your server

Each snippet below matches a file pattern and attaches the header. Pick the layer that serves the response, because a header set at the origin can be overwritten or stripped further down the chain.

Apache and .htaccess

Apache sets response headers with the Header directive from mod_headers. Google's example adds noindex, nofollow to every PDF from the root .htaccess file or httpd.conf:

<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>

Google's image example uses the same structure:

<Files ~ "\.(png|jpe?g|gif)$">
Header set X-Robots-Tag "noindex"
</Files>

Apache's core documentation says <FilesMatch> is preferred over <Files ~> for regular expressions. Its example starts the pattern with .+ so that bare files named .png or .gif don't match:

<FilesMatch ".+\.(gif|jpe?g|png)$">
Header set X-Robots-Tag "noindex"
</FilesMatch>

Use set and not add. The mod_headers reference warns that add can produce two headers with the same name. Two more details catch people out:

  • .htaccess files are ignored unless the server config allows overrides, and Header needs at least AllowOverride FileInfo to work there.
  • Apache's documentation says to add the always condition (Header always set ...) if the header must appear on non-2xx responses such as redirects and errors.

Nginx

Add add_header within the NGINX location that already serves the file. The examples show how to match PDFs and images by extension. Keep the existing proxy or file handler in place, and confirm that the file still returns the expected status and content:

location ~ \.pdf$ {
  add_header X-Robots-Tag "noindex, nofollow";
}

location ~ \.(png|jpe?g|gif)$ {
  add_header X-Robots-Tag "noindex";
}

Two behaviors in the headers module decide whether the header goes out. Without the always parameter, add_header only fires on 200, 201, 204, 206, 301, 302, 303, 304, 307 and 308 responses. Write add_header X-Robots-Tag "noindex" always; if 404s and 500s need it too.

Inheritance causes the larger problem. Nginx inherits add_header directives from the parent level only if the current level defines none. So a location block with its own add_header silently drops every header set at the server level. Nginx 1.29.3 added add_header_inherit merge; to append the parent's headers instead. On older versions, repeat the server-level headers inside the location.

IIS, Cloudflare and other CDNs

IIS sets custom headers in web.config under system.webServer/httpProtocol/customHeaders. Microsoft's customHeaders reference uses this structure, shown here with the X-Robots-Tag name and value:

<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-Robots-Tag" value="noindex" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

Custom headers go out on every response in scope. To limit the header to one folder, place that web.config in the folder itself, because IIS accepts the section at the directory level web.config.

To send the header only for certain file types, you need the URL Rewrite module. Within it, an outbound rule can write to a RESPONSE_ server variable, and IIS converts its underscores to dashes in the header name. Distributed rules can only set server variables that an administrator has added to the Allowed Server Variables list.

On Cloudflare, use a Response Header Transform Rule. Cloudflare's dashboard steps follow this sequence:

  1. Go to Rules, open Overview and select Create rule > Response Header Transform Rule.
  2. Name the rule and choose Custom filter expression. Match the exact hostname and path or directory you intend to exclude. For one PDF, use an expression like (http.host eq "www.example.com" and http.request.uri.path eq "/downloads/guide.pdf").
  3. Under Modify response header, choose Set static, enter X-Robots-Tag as the header name and noindex as the value.
  4. Confirm the filter matches only the intended URLs, then select Deploy. Use curl -sS -D - -o /dev/null on a target URL and an indexable production URL outside the filter. The target should send the header and the production URL should remain free of this noindex directive.

Set static overwrites any existing header with the same name, which avoids duplicate X-Robots-Tag lines from origin and edge. Regex matching in Transform Rules is limited to Business and Enterprise plans.

Other CDNs have their own equivalents:

  • AWS CloudFront: Create a response headers policy with a custom header and attach it to a cache behavior. The override setting decides whether CloudFront replaces a header the origin already sent.
  • Fastly: Set resp.http.X-Robots-Tag in vcl_deliver, or use the Headers UI with the Set action.
  • Akamai: Use the Property Manager behavior Modify Outgoing Response Header and enter the name under the Other option.

How to check whether a URL sends an X-Robots-Tag header

You need to check the live response, not the config file. The config shows what you intended, and the response shows what crawlers get after every server, plugin and CDN layer has had its turn.

A request returns a response whose header section contains the X-Robots-Tag to inspect.
Look for the directive in the HTTP response headers.

curl and browser dev tools

Use a GET request to check the same response crawlers fetch. This command prints the response headers and discards the body. A PDF carrying noindex can return the following:

$ curl -sS -D - -o /dev/null https://example.com/guide.pdf
HTTP/2 200
content-type: application/pdf
content-length: 482113
x-robots-tag: noindex

HEAD should return the same headers a GET would, minus the body. But curl's own documentation notes that some servers deny HEAD. If -I returns an error or hangs, run curl -i instead, which makes a normal GET and prints the headers above the body.

In Chrome, follow the steps in the DevTools network reference:

  1. Open DevTools and select the Network tab, then reload the page or open the file URL.
  2. Select the request under the Name column.
  3. Open the Headers tab and scroll to Response Headers.

To scan every request at once, press Control+F (Command+F on macOS) inside the Network panel and search for x-robots-tag.

Google Search Console URL Inspection

URL Inspection shows what Google saw, which is the version that counts. Its "Indexing allowed?" field reports whether the URL explicitly disallowed indexing, and Google's Help page says a "No" there means the URL is returning a noindex tag or header. Users in Google's Search Central Community have posted the header version of the message as No: 'noindex' detected in 'X-Robots-Tag' http header, and the meta version names the 'robots' meta tag instead, so that wording tells you which layer to fix.

Run the live test after you change the header, then check Availability > Indexing > Indexing allowed? to see whether Google still detects the noindex. Across the whole property, the Page indexing report lists affected URLs under the reason "URL marked ‘noindex’".

Common X-Robots-Tag mistakes and fixes

Most X-Robots-Tag failures come from a header Google never reads, two signals that disagree, or a header nobody meant to send.

Blocking the URL in robots.txt

A robots.txt disallow hides your noindex, because Google can't crawl the URL, so it never sees the header. And Google's robots.txt guide says a disallowed URL can still be indexed if other pages link to it. It shows up with no description.

For example, you add noindex headers to /downloads/*.pdf and, for good measure, add Disallow: /downloads/ to robots.txt. The PDFs stay in the index, now without snippets, because Googlebot stopped fetching them before it could read the header. URL Inspection makes this worse to diagnose: when robots.txt blocks a URL, "Indexing allowed?" always shows "Yes," since Google can't see the noindex.

Remove the disallow and leave the header in place so Google can recrawl. Keep the URLs crawlable for as long as the header is your permanent removal method.

Conflicting header and meta robots values

Google applies the more restrictive rule when robots rules conflict. Its own example pairs max-snippet:50 with nosnippet, and nosnippet wins.

Apply that to a split setup. An HTML page sends X-Robots-Tag: nosnippet from a CDN rule while the template's meta tag says max-snippet:50. Google treats the page as nosnippet, so it shows no text snippet and the content stays out of direct inputs for AI Overviews and AI Mode.

Pick one layer as the owner for each page type and remove the other signal.

An unwanted noindex header

An unexpected header usually surfaces as URLs under "URL marked ‘noindex’" in the Page indexing report, while the page source looks clean. Search Console's Help says you must remove the tag or HTTP header to get the page indexed. When the HTML has no meta tag, check these layers in order:

  • CMS-level settings that discourage search engines across a whole website, often left on after launch
  • SEO and security plugins that add response headers outside the template
  • Staging configs copied into production, such as a server block or .htaccess file with a host-wide noindex
  • Caching layers that stored a response from when the header was on
  • CDN rules (Transform Rules, response headers policies, VCL) that add the header at the edge
  • Default headers on sitemap files, which some setups send with noindex

Confirm each fix with curl from outside your network, then run a live test in URL Inspection. Request indexing when the corrected page is eligible and you want it in search.

The X-Robots-Tag sits alongside several other controls, and each one does a different job:

  • robots.txt: It controls crawling, not indexing, and a disallow stops crawlers from reading any X-Robots-Tag on the blocked URLs.

  • Canonical tags: They consolidate duplicate URLs onto one version, while noindex removes a URL from results.

  • Crawl budget: noindex URLs still get crawled, because crawling is how Google reads the header.

AI crawler access is a separate control, and Google points to nosnippet, max-snippet and noindex to limit what appears from your pages in Search, including AI Overviews and AI Mode. Training and grounding for Gemini Apps and Vertex AI run through the Google-Extended token in robots.txt, and

Google's crawler documentation says that token doesn't affect inclusion in Google Search. Bing is moving the same way: it says NoArchive and NoCache won't be honored for training after March 1, 2027, and that new ai-training and ai-grounding preferences replace them.

Run curl -sS -D - -o /dev/null against one PDF and one HTML page today and confirm that the X-Robots-Tag you expect is the one each URL sends.