This might help (Perplexity.com provided):
To enhance the security of your website and ensure international compliance, you can add several important HTTP security headers to your .htaccess
file. Below is a comprehensive list of headers along with their recommended configurations.
Recommended Security Headers
1. Content Security Policy (CSP)
This header helps prevent cross-site scripting (XSS) attacks by specifying which content sources are allowed.
<IfModule mod_headers.c>
Header set Content-Security-Policy "default-src 'self'; img-src 'self' data:; script-src 'self'; style-src 'self';"
</IfModule>
2. Strict-Transport-Security (HSTS)
This header enforces the use of HTTPS and prevents users from accessing the site over HTTP.
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</IfModule>
3. X-XSS-Protection
This header enables the browser’s built-in XSS protection.
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
</IfModule>
4. X-Frame-Options
This header prevents clickjacking by controlling whether your site can be embedded in an iframe.
<IfModule mod_headers.c>
Header set X-Frame-Options "SAMEORIGIN"
</IfModule>
5. X-Content-Type-Options
This header prevents browsers from MIME-sniffing a response away from the declared content type.
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
</IfModule>
6. Referrer-Policy
This header controls how much referrer information is passed when navigating from your site.
<IfModule mod_headers.c>
Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
7. Permissions-Policy
This header allows you to control which features can be used in your web application.
<IfModule mod_headers.c>
Header set Permissions-Policy "geolocation=(self), vibrate=()"
</IfModule>
Implementation Steps
-
Access Your .htaccess File: Log in to your server via SFTP or SSH, navigate to the webroot (usually /public/
), and open the .htaccess
file for editing.
-
Add the Security Headers: Insert the recommended headers within <IfModule mod_headers.c>
tags to ensure they are only applied if the module is enabled.
-
Validate Changes: Save the changes and use tools like securityheaders.com to verify that your headers are correctly implemented.
By adding these headers, you can significantly improve your website’s security posture and help ensure compliance with various international regulations, such as GDPR, which mandates certain privacy protections[1][2][3].
Citations:
[1] How to Add HTTP Security Headers to Your Site » Servebolt
[2] How to Add Security Headers to Your Website Using .htaccess
[3] Seven Important Security Headers for Your Website | .htaccess made easy
[4] How to Add HTTP Security Headers in WordPress (Ultimate Guide) » Servebolt
[5] htaccess passing with Security Headers - General topics - PrestaShop Forums
[6] HTTP Security Headers: An Easy Way To Harden Your Web Applications
[7] HTTP Headers - OWASP Cheat Sheet Series