Security
HTTP Security Headers Explained: HSTS, CSP, X-Frame-Options and More
What the main HTTP security headers do, which ones every website should send, example values and how to add them on Apache, Nginx and WordPress.
Security headers are short instructions your server sends with every page, telling the browser how strictly to behave. They cost nothing, take minutes to add and block entire classes of attack. GDPR asks for "appropriate technical measures": these are some of the easiest visible ones.
Strict-Transport-Security (HSTS)
Forces browsers to use HTTPS for your domain. Example: Strict-Transport-Security: max-age=31536000; includeSubDomains. Enable it only when every subdomain works over HTTPS.
Content-Security-Policy (CSP)
Lists where scripts, styles, images and frames may be loaded from, which greatly limits cross-site scripting and data exfiltration. A starting point is default-src 'self', then allow only what you really use. It is the most powerful header and the one that needs testing.
X-Content-Type-Options
X-Content-Type-Options: nosniff stops browsers from guessing file types, preventing some script-injection tricks.
X-Frame-Options or frame-ancestors
X-Frame-Options: SAMEORIGIN (or the CSP directive frame-ancestors) prevents other sites from embedding yours in a frame, defeating clickjacking.
Referrer-Policy
Referrer-Policy: strict-origin-when-cross-origin limits how much of your URLs is leaked to other sites, which also helps privacy.
Permissions-Policy
Switches off browser features you do not use, such as camera, microphone or geolocation, so a compromised script cannot use them.
How to add them
- Apache:
Header always set ...in.htaccess(needs mod_headers). - Nginx:
add_header ... always;in the server block. - WordPress: a security plugin or server-level configuration; avoid editing theme files.
Test and monitor
After changes, reload the site and watch the browser console for blocked resources. A Lawscan scan includes a technical snapshot of the security headers actually sent, with a suggested fix for each missing one.
Related checks in the Compliance Index
Find out what your website is missing
Scan it for free, then ask for a full report with a prioritised action plan.
Prefer expert help? Request a full compliance report →
Keep reading
- Security
WordPress Security and GDPR: A 12-Step Hardening Checklist
Secure your WordPress site and protect personal data: updates, 2FA, backups, login protection, roles, plugins and monitoring in 12 steps.
November 18, 2026 · 6 min read - Security
Data Breach on Your Website: What to Do in the First 72 Hours
What counts as a personal data breach, when to notify the authority and users, and a step-by-step response plan for the first 72 hours.
November 6, 2026 · 6 min read - Legal & e-commerce
Children and Minors Online: GDPR Rules for Websites Aimed at Young Users
Age of digital consent, parental authorisation, clear language and safer defaults: what the GDPR requires if children use your website.
November 25, 2026 · 5 min read
This guide is for general information and is not legal advice. Rules change and national laws vary: check with a qualified professional for your specific case.