2

Setting referrer on Chrome using this PHP header will set all page referrers to none/no-referrer: "Referrer-Policy" => "no-referrer"

I have a problem to set the same Referrer policy to "no-referrer" on Firefox, because seems the same PHP header doesn't work.

The solution must be in PHP, I cannot accept solution through META tags or JS.

( "Referrer-Policy" => "no-referrer" )

This should set referrer to none, empty on Firefox, but it doesn't.

On Chrome it works without any problem.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197

2 Answers2

4

( "Referrer-Policy" => "no-referrer" )

This is not a valid PHP HTML Header.

The PHP header() functions contain a text string of "<Header>:<value>" format so;

header("Referrer-Policy: no-referrer");

This will set the header correctly, however depending on your server setup this may be ommitted if the same header has already been set elsewhere, such as in httpd.conf on Apache, or if the Header has been set elsewhere with the always keywords, such as in .htaccess on Apache.

Martin
  • 22,212
  • 11
  • 70
  • 132
  • The code I sent you is actually from our lighttpd config, its adding header to set referrer policy to no referrer for Chrome, but for FireFox it doesnt work. Same goes for: header("Referrer-Policy: no-referrer"); Its setting referrer for Chrome but FireFox doesnt react to referrer changes. – Drago Dragičević Feb 06 '19 at 21:52
0

The question is not actual for its author, but I`ll add an answer for the newest visitors:

the "Referrer-Policy" header did not work via PHP (modern virtual hosting), but it works fine if added to .htaccess file. The syntax is:

<IfModule mod_headers.c>
    Header set Referrer-Policy "same-origin"
</IfModule>
Andrews32
  • 47
  • 1
  • 5