Referrer Policy in Prestashop 1.6

noobseeker

New member
XNullUser
Joined
May 25, 2022
Messages
8
Reaction score
0
Points
1
NullCash
4
Hi,

Here is a tip to add a Referrer Policy to your HTTP Header in Prestashop 1.6 :

- You need to Edit or override /classes/controller/FrontController.php
- Search function initHeader (~ lines 997)
Code:
public function initHeader()

- Insert this line
Code:
header('Referrer-Policy: strict-origin-when-cross-origin');
after
Code:
header('Powered-By: PrestaShop');

- Modify 'strict-origin-when-cross-origin' according to the policy rule you need.

Code:
public function initHeader()
    {
        /** @see P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) */
        header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
        header('Powered-By: PrestaShop');
        header('Referrer-Policy: strict-origin-when-cross-origin');
 
Top