How to Set the Referrer-Policy Header

Referrer-Policy controls how much of your page URL is shared with other sites when users click links. This guide shows how to set it on all major web servers and platforms.


The Referrer-Policy header controls how much URL information the browser includes in the Referer header when users navigate away from your pages. Without it, sensitive URL paths — including query strings with user IDs or session tokens — can leak to third-party sites. This guide shows how to set the header across all major web servers and platforms.

Choosing a Policy Value

ValueWhat Is SentBest For
no-referrerNothing — Referer header is omitted entirelyMaximum privacy; breaks referrer-based analytics
no-referrer-when-downgradeFull URL on HTTPS→HTTPS; nothing on HTTPS→HTTPLegacy default; not recommended (leaks paths to same-scheme third parties)
strict-origin-when-cross-originFull URL on same-origin; origin only on cross-origin HTTPS; nothing on HTTPRecommended for most sites — good balance of privacy and analytics
strict-originOrigin only on HTTPS; nothing on HTTP downgradesSites that need to minimise referrer data to third parties
same-originFull URL on same-origin only; nothing cross-originSites that want no referrer data sent to any third party
originOrigin only, alwaysSites needing referrer data but not full paths
unsafe-urlFull URL always, including to HTTP sitesAvoid — leaks sensitive paths even on downgrades
Recommended Valuestrict-origin-when-cross-origin is the browser default since Chrome 85 and the recommended value for most sites. Setting it explicitly ensures consistent behaviour across all browsers and documents your intent for security auditors.

Nginx

nginx
server { listen 443 ssl; server_name example.com; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # ... rest of config }
bash
sudo nginx -t && sudo systemctl reload nginx

Apache

apache
<VirtualHost *:443> <IfModule mod_headers.c> Header always set Referrer-Policy "strict-origin-when-cross-origin" </IfModule> </VirtualHost>

Or in .htaccess:

apache
<IfModule mod_headers.c> Header always set Referrer-Policy "strict-origin-when-cross-origin" </IfModule>
bash
sudo a2enmod headers && sudo systemctl reload apache2

IIS (web.config)

xml
<system.webServer> <httpProtocol> <customHeaders> <add name="Referrer-Policy" value="strict-origin-when-cross-origin" /> </customHeaders> </httpProtocol> </system.webServer>

Caddy

Command
example.com { header Referrer-Policy "strict-origin-when-cross-origin" # ... rest of config }

Cloudflare (Transform Rules)

  1. Go to RulesTransform RulesModify Response Header.
  2. Add a rule with Operation: Set, Header name: Referrer-Policy, Value: strict-origin-when-cross-origin.
  3. Deploy the rule.

Next.js

javascript
// next.config.mjs const nextConfig = { async headers() { return [ { source: '/(.*)', headers: [ { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin', }, ], }, ]; }, }; export default nextConfig;

Setting via HTML Meta Tag

You can also set a per-page referrer policy using an HTML <meta> tag in the <head>. This is useful for pages where you need a different policy than the server-wide default:

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

The HTTP header takes precedence over the meta tag when both are present.

Verifying the Header

bash
curl -I https://example.com | grep -i referrer # Expected: referrer-policy: strict-origin-when-cross-origin

Or use the ShowDNS Security Headers Scanner.

Related Articles