How to add a Referrer-Policy header

Send Referrer-Policy strict-origin-when-cross-origin so other sites see only your domain, not the full address of the page a visitor came from.

Last reviewed

Why it matters

When a visitor follows a link or the page loads something from another site, the browser sends the address it came from. Without a policy, some browsers can send the full address, including search terms, order numbers or reset tokens in the query string; setting it makes the behaviour the same everywhere.

How to fix it

Use strict-origin-when-cross-origin: the full address within your site, only the origin to other HTTPS sites, nothing to HTTP sites. It is already the default in current browsers; setting it pins it for the rest.

Replace the highlighted values: www.example.com with the site's hostname.

Cloudflare

Rules > Overview > Create rule > Response Header Transform Rule, name it, apply it to all incoming requests, choose Set static with Header name Referrer-Policy and Value strict-origin-when-cross-origin, and Deploy.

Source: create a response header rule.

nginx

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

Source: ngx_http_headers_module.

Apache

<IfModule mod_headers.c>
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

Source: mod_headers.

Caddy

header Referrer-Policy "strict-origin-when-cross-origin"

Source: the header directive.

Vercel

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }]
    }
  ]
}

Source: vercel.json.

Netlify

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

Source: Netlify custom headers.

WordPress

Plugin route (HTTP Headers): Settings > HTTP Headers > Security, Edit next to Referrer-Policy, select On, choose strict-origin-when-cross-origin, and Save Changes.

Code route: inside the send_headers function in wp-content/mu-plugins/security-headers.php (see the HSTS guide for the file):

header( 'Referrer-Policy: strict-origin-when-cross-origin' );

Sources: HTTP Headers plugin, send_headers.

Shopify

Shopify documents no way for merchants to set response headers. A theme can add <meta name="referrer" content="strict-origin-when-cross-origin"> in its <head>, which browsers honour, but it is not a header, so this finding stays.

Source: MDN: Referrer-Policy.

Check that it worked

curl -sI https://www.example.com/ | grep -i referrer-policy

In devtools > Network, click a request to another site and confirm its Referer shows only https://www.example.com/. Then run the Owl Keeper Security headers check again.

Test it now with the free HTTP status code checker. No account needed.

What can go wrong

  • Low. Analytics, affiliate and ad partners stop seeing the full path and query string, so some referral reports show less detail.
  • Rare server-side checks that compare the full Referer on requests from other sites (some payment returns, anti-hotlinking) may need adjusting. Stricter values such as no-referrer break more of these.