Home / Fix guides / Website security

How to add a Referrer-Policy header to your website

Add a Referrer-Policy response header with the value strict-origin-when-cross-origin on your web server, CDN or hosting platform. It takes a few minutes and stops your site from leaking full page addresses to other websites.

A Referrer-Policy header is a short instruction your website sends along with every page. It tells the visitor's browser how much information about the previous page to pass on when they click a link, load an image or call another service. If the header is missing, the browser falls back to its own default. You won't see anything wrong on the page itself. The problem shows up in security scans, which flag it as a missing header.

What the problem is and what you see

When someone clicks a link on your site to another site, the browser can send a Referer header (yes, spelled that way) containing the address of the page they came from. That address can include more than you expect: search terms, order or account numbers, password reset tokens, or the names of private pages.

Without a Referrer-Policy, modern browsers such as current Chrome, Firefox, Edge and Safari apply a sensible default (strict-origin-when-cross-origin). But you are relying on the visitor's browser, and older or unusual browsers may behave differently. A scanner reports the header as missing because your site never stated its own rule.

Why it matters

  • Privacy and security: full page addresses sent to third parties (analytics, ad networks, embedded maps, payment pages, social buttons) can expose private details in the URL.
  • Trust and compliance: if your URLs contain personal data, passing them to other companies can create a data protection problem.
  • Consistency: you choose the behaviour instead of leaving it to each browser.
  • Scan results: it is a low severity finding, but it is quick to fix and removes noise from security reports.

This is not a ranking factor for search engines and it will not break your site. One side effect to know about: analytics tools on other sites may see less detail about where your traffic came from. With the recommended value, other sites still see your domain name, just not the full page path.

How to check if your site has it

There are three free ways.

  1. Browser developer tools. Open your site, press F12, go to the Network tab, reload, click the first request (your page), and look under Response Headers for referrer-policy.
  2. Command line. Run this and look for the line in the output:
curl -sI https://www.example.com | grep -i referrer-policy
  1. An online header checker. The free tool at securityheaders.com lists the headers your site sends and flags the ones that are missing.

Check your home page and one inner page. Sometimes a header is set only on some paths.

How to fix it in general

The best place to set the header is wherever your site is served from: the web server, a CDN, or your hosting platform. The value most sites should use is:

Referrer-Policy: strict-origin-when-cross-origin

This sends the full address for links within your own site, only your domain name to other sites, and nothing at all when going from secure HTTPS to insecure HTTP. If your pages handle very sensitive addresses, same-origin (nothing sent to other sites) or no-referrer (nothing sent anywhere) are stricter choices. Avoid unsafe-url, which sends the full address everywhere.

If you cannot touch server settings, you can put a tag in the <head> of your pages instead:

<meta name="referrer" content="strict-origin-when-cross-origin">

This works in browsers, but a real header is preferred because it covers every response and is what scanners look for.

Fixing it on common platforms

Exact menus and file locations depend on your host and version, so treat these as the usual places to look.

Nginx. In your server block (often in a file under /etc/nginx/sites-available/ or /etc/nginx/conf.d/), add the line below, then test and reload with nginx -t and systemctl reload nginx. There is a longer walkthrough in the Nginx guide.

add_header Referrer-Policy "strict-origin-when-cross-origin" always;

Apache. Make sure mod_headers is enabled, then add this to your site config or .htaccess:

Header always set Referrer-Policy "strict-origin-when-cross-origin"

WordPress. There is usually no built in setting. The cleanest route is the Apache or Nginx method above, or your host's control panel if it has a headers option. Some security plugins can also add response headers. See the WordPress guide for the options and what to watch for with caching.

Cloudflare. In the dashboard, look under Rules, then Transform Rules, then Modify Response Header. Add a rule that sets the header Referrer-Policy to your chosen value for all requests.

Netlify. Add a _headers file in your published folder with /* on one line and Referrer-Policy: strict-origin-when-cross-origin indented on the next, or use a [[headers]] block in netlify.toml.

Vercel. Add a headers entry in vercel.json with source /(.*) and the key Referrer-Policy.

Next.js. Add an async headers() function in next.config.js that returns the same key and value for all paths.

Shared hosting. If you cannot edit server files, check the control panel for a headers or security section, or ask your host's support to add the header. Send them the exact line from this page.

How to confirm the fix worked

  1. Clear any cache: your site cache plugin, your CDN cache, and your browser cache.
  2. Run the curl -sI command again, or reload the Network tab, and confirm referrer-policy shows your value.
  3. Check an inner page, a login page and a static file such as an image, since some setups only add headers to certain responses.
  4. Click a link to an external site and make sure everything on your own site still works, especially login, checkout and any embedded payment or map services.
  5. Run the header checker again and confirm the warning is gone.

If the header appears twice with different values, one rule is coming from your app and another from the server or CDN. Remove one so the result is predictable.

How to stop it coming back

Headers often disappear after a server migration, a new hosting plan, a rebuilt Nginx config or a CDN change, because the setting lived in a file nobody copied across. Keep a note of your security headers in your project documentation, and recheck after any hosting change.

The Referrer-Policy header usually travels with other security headers. If this one was missing, check the rest too, starting with the Content-Security-Policy header.

SiteMonday runs an OpenVAS security scan in week 2 of its 52 week programme, once you have proven you own the site. The report lists findings like this one in a ranked fix list, so you can pass it to your developer. SiteMonday finds and explains the problem; making the change is up to you or your developer.

Step by step for your platform

Questions

Which Referrer-Policy value should I use?

For most websites, `strict-origin-when-cross-origin` is a good choice. Use `same-origin` or `no-referrer` if your page addresses contain sensitive information.

Will adding a Referrer-Policy header break my website?

It is very unlikely to. The main thing to test is third party tools that rely on knowing the full page address, such as some analytics, affiliate or payment integrations.

Do I need both the header and the meta tag?

No. The header is preferred because it covers every response. The meta tag is a fallback when you cannot change server settings.

Does a missing Referrer-Policy hurt my search rankings?

Not directly. It is a privacy and security setting, not a search ranking factor.

Why does the scan still say it is missing after I added it?

Usually a cache is serving the old response, or the header was added only to some paths. Clear your site and CDN caches, then check the exact address the scanner tested.

Can I set this header without editing server files?

Often yes. A CDN such as Cloudflare, a hosting control panel or your platform's config file (like `netlify.toml` or `vercel.json`) can add it. A meta tag in your page head is the last resort.

Related problems