Oleksii Khoroshun, k-o.pro homeAudits and advisory

X-Robots-Tag: Syntax, Server Configs and How to Debug a Hidden Noindex

X-Robots-Tag sets noindex and other indexing rules in the HTTP header. Syntax, Apache, Nginx, Next.js and Vercel configs, and how to find a hidden noindex.

Oleksii KhoroshunSEO at SE Ranking9 min read2,013 words

X-Robots-Tag is an HTTP response header that carries the same indexing rules as the robots meta tag. It is the only way to put noindex on a file that has no HTML head, such as a PDF, and one rule can cover a whole path pattern from server config. Two things go wrong with it in practice: the rule is never read because robots.txt blocks the URL, or a noindex appears that nobody remembers setting.

This guide covers the syntax, the directives Google and Bing support, working configs for Apache, Nginx, Next.js, Vercel and Cloudflare, and a method for finding where a stray noindex header comes from. Technical details were checked against Google, MDN, Bing and server documentation on Oct 23, 2026.

What X-Robots-Tag controls

X-Robots-Tag tells search engines how to index and serve a URL. MDN describes it as a de-facto standard that is not part of any specification, and notes that only cooperative robots follow it. Three mechanisms get mixed up:

  • robots.txt controls crawling. It says which URLs a bot may request and nothing about indexing. Google stopped supporting noindex inside robots.txt, as it explained in July 2019.
  • The meta robots tag controls indexing and serving for one HTML page and sits in the page's <head>.
  • X-Robots-Tag controls the same for any URL, HTML or not, and sits in the response header. Because it is set in server config, one rule can cover a file type or a path pattern, which the meta tag cannot do.

Use robots.txt to stop a bot from requesting a URL. Use X-Robots-Tag or the meta tag when the bot should fetch the URL but the URL should stay out of results.

Syntax

Any rule that works in a robots meta tag also works as an X-Robots-Tag, according to Google's specification (last updated Mar 24, 2026). The header name, the bot name and the values are case-insensitive. A minimal response:

HTTP/1.1 200 OK
X-Robots-Tag: noindex

Rules can be comma-separated in one header or split across several headers:

X-Robots-Tag: noimageindex
X-Robots-Tag: unavailable_after: 2026-12-31T23:59:59Z

To limit a rule to one crawler, put the bot name first. A rule without a bot name applies to all crawlers:

X-Robots-Tag: nofollow
X-Robots-Tag: googlebot: noindex

Per MDN, Googlebot reads this response as noindex, nofollow, because the general rule and the bot-specific rule add up. When rules conflict, the more restrictive one applies, both inside the header and between the header and the meta tag. Values that contradict each other, such as index and noindex, give undefined behavior. Google does not list index or follow as rules, since both are the default.

One consequence matters when you debug: you cannot cancel a noindex set in one layer by sending index from another. The restrictive rule wins, so the noindex has to be removed where it is set.

Directives

  • noindex: keep the URL out of results. Google drops the page after it recrawls it and sees the rule.
  • nofollow: do not follow the links on the page.
  • none: the same as noindex, nofollow.
  • nosnippet: no text snippet or video preview. A static thumbnail may still appear.
  • max-snippet:[number]: cap the snippet at that many characters. 0 works like nosnippet and -1 lets Google choose the length.
  • max-image-preview:[none|standard|large]: set the largest image preview allowed.
  • max-video-preview:[number]: cap the video preview in seconds. 0 allows at most a static image and -1 means no limit.
  • noimageindex and notranslate: do not index images on the page, and do not offer a translation in results.
  • unavailable_after:[date]: stop showing the page after a date. Google accepts RFC 822, RFC 850 and ISO 8601 formats and ignores invalid values.
  • indexifembedded: lets Google index the content of a noindex page when it is embedded in another page through an iframe. It has an effect only together with noindex. Google introduced it in January 2022.

noarchive and nocache need a separate note. Google's specification lists both as unused by Google Search. Bing supports both and says each tag can also be sent as an X-Robots-Tag, but they are not the same. With noarchive, Bing does not link the page in Chat and Copilot and does not use the content to train Microsoft's generative AI foundation models. With nocache, Bing shows only the URL, title and snippet in Chat or Copilot and uses only those for training. If a page has both tags, Bing treats it as nocache. Bing's name for its crawler in meta tags is bingbot.

When robots.txt hides the header

A crawler has to fetch a URL before it can read that URL's headers. Google's specification says it directly: if a page is disallowed from crawling in robots.txt, any information about indexing or serving rules "will not be found and will therefore be ignored". Google's noindex guide adds that the page can then still appear in results. Bing's documentation gives the same warning for noindex.

The fix is to allow crawling in robots.txt and let the header handle indexing. Blocking both does not stack the protection. Check what robots.txt blocks before you add any X-Robots-Tag rule, or the rule will never be read.

Set it up

Scope every rule to the narrowest file type or path pattern that covers the case. A rule on /:path* in Next.js or a catch-all location block in Nginx is one typo away from removing the whole site from search.

Apache

This is Google's own example for PDF files, in .htaccess or the server config:

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

Header set writes to Apache's default onsuccess header table. According to the mod_headers documentation, the always condition adds a header on error responses too, so use Header always set if the header must appear on redirects and errors.

Nginx

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

Google's example omits always. Per the Nginx documentation, add_header applies by default only to responses with code 200, 201, 204, 206, 301, 302, 303, 304, 307 or 308, and always removes that limit. The same page explains inheritance: directives are inherited from the previous level only if the current level has no add_header of its own. A header set at server level therefore disappears from any location that defines a different add_header.

Next.js

For a static rule tied to a path pattern, use headers() in next.config.js:

module.exports = {
  async headers() {
    return [
      {
        source: '/preview/:path*',
        headers: [{ key: 'X-Robots-Tag', value: 'noindex' }],
      },
    ]
  },
}

To apply a rule to one hostname, such as a staging domain, add a has condition. The Next.js documentation lists host as a valid type:

module.exports = {
  async headers() {
    return [
      {
        source: '/:path*',
        has: [{ type: 'host', value: 'staging.example.com' }],
        headers: [{ key: 'X-Robots-Tag', value: 'noindex' }],
      },
    ]
  },
}

If the rule has to be decided at request time, set the header in the proxy file. Next.js 16 deprecated the middleware file convention and renamed it to proxy, so older guides that show middleware.ts are outdated:

import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export function proxy(request: NextRequest) {
  const response = NextResponse.next()
  response.headers.set('X-Robots-Tag', 'noindex')
  return response
}

export const config = {
  matcher: '/preview/:path*',
}

Vercel

Outside Next.js, or when you want the rule at the platform level, use vercel.json:

{
  "headers": [
    {
      "source": "/documents/(.*).pdf",
      "headers": [{ "key": "X-Robots-Tag", "value": "noindex" }]
    }
  ]
}

Vercel also sets this header on its own, which is covered in the debugging section below.

Cloudflare

A Worker in front of any origin can add the header for matching paths. The response has to be copied before its headers can be changed:

export default {
  async fetch(request) {
    const response = await fetch(request)
    const url = new URL(request.url)
    if (!url.pathname.endsWith('.pdf')) return response

    const modified = new Response(response.body, response)
    modified.headers.set('X-Robots-Tag', 'noindex')
    return modified
  },
}

Without code, a response header Transform Rule does the same job. Its Set operations replace all existing headers of that name, and Add operations keep them.

Check what a URL returns

The header is not in the page source. Request the URL and print the response headers:

curl -s -o /dev/null -D - https://example.com/report.pdf

The output should contain the header:

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

This sends a GET request. curl -I sends HEAD, and a server can answer the two differently. I confirmed the difference locally with a test server I wrote to send the header only on GET: curl -I showed no X-Robots-Tag and the GET request did. For an indexing rule, check with GET. In a browser, open DevTools, select the request in the Network tab and read the Response Headers.

For a faster check without a terminal, I built X-Robots-Tag detection into my HTTP status tool. Paste a URL and it shows the status code, redirect chain and response headers, including X-Robots-Tag, in one pass. I added it after losing time to exactly this bug: a staging subdomain got indexed because the header was set on the wrong path pattern. My Chrome extension, Keep Optimized, does the same header check from the toolbar while you are on the page, which is faster when you audit as you browse.

Search Console shows what Google saw. According to Google's Page indexing help, the report lists the status "URL marked 'noindex'", and URL Inspection shows whether indexing is allowed for a specific URL.

Find a noindex header you did not set

A request can pass through an edge rule on a CDN, the web server config, the framework, a CMS or plugin, and the hosting platform's defaults. Each layer can add its own X-Robots-Tag. When Search Console reports a noindex that is not in your config, work through these steps:

  1. Request the public URL with the GET command above and note every x-robots-tag line. Two lines mean two layers.
  2. Request the same path directly from the origin server, bypassing the CDN, with --resolve. Use your origin's IP address in place of the placeholder. If the header appears only on the public request, the source is an edge rule.
  3. Compare a file, a page and the homepage. A header that appears only on one pattern points to a path-scoped rule.
  4. Search the server config for the string x-robots-tag, including .htaccess files in parent directories.
# Origin request, bypassing the CDN (203.0.113.10 is a placeholder IP)
curl --resolve example.com:443:203.0.113.10 -s -o /dev/null -D - https://example.com/report.pdf

# Search server config for the header
grep -rn -i "x-robots-tag" /etc/nginx/
find /var/www -name .htaccess -exec grep -il "x-robots-tag" {} +

Hosting platforms set the header without being asked. Vercel's guide on preview indexing (updated Oct 2, 2026) says Vercel adds X-Robots-Tag: noindex to every Preview Deployment automatically. When you promote a new deployment, the previous production deployment starts returning noindex. The header is omitted when a custom domain is assigned to a non-production branch, so that domain can be indexed unless you add your own rule.

A staging config copied to production is the other usual cause, and it is the reason to check response headers on the live domain right after every deploy or migration.

After the source is fixed, Google acts only when it recrawls the URL. You can ask Google to recrawl from URL Inspection.

FAQ

What does "noindex detected in X-Robots-Tag HTTP header" mean?

It is Search Console telling you that the response for that URL carried a noindex rule in the header, so Google will not index it. It is a diagnosis, not a crawl error. If the rule is intended, leave it. If it is not, find the layer that sends it with the steps above and remove it there.

Does X-Robots-Tag work on JavaScript-rendered pages?

Yes. The server sends the header before any JavaScript runs. Google's JavaScript SEO guide (updated Mar 4, 2026) says Google renders pages with a 200 status unless a robots meta tag or header tells it not to index the page, and that when it meets noindex it may skip rendering and JavaScript execution. Using JavaScript to remove a noindex "may not work as expected". If you want the page indexed, do not ship a noindex in the header or the original HTML.

Does Bing support X-Robots-Tag?

Yes. Bing's documentation lists noindex, noarchive, nocache, nosnippet, max-snippet, max-image-preview and max-video-preview, and says each can also be sent as an X-Robots-Tag header. Search Engine Journal reported Bing's support for the three max- controls on Apr 8, 2020. Support in other crawlers varies, so test with the crawler you care about.

Is the "X-" prefix outdated?

RFC 6648 (June 2012) deprecates the convention for newly defined parameters. It does not require renaming headers already in use, and X-Robots-Tag is still the name Google and Bing document.

Where to start

List the non-HTML files and the staging hosts that matter, request each with the GET command, and confirm that robots.txt is not blocking any of them. Fix the robots.txt rule before you touch the header.

That covers the case where a page is indexed and should not be. If your problem runs the other way and a page you want indexed will not show up, X-Robots-Tag is not the cause. See why pages get stuck as "discovered, currently not indexed".

Open for select advisory

Audits and advisory

Fixed-scope audits and strategic guidance across search architecture, AI visibility, and automation. Currently taking on select projects.