How to Add the HSTS Header
Tell browsers to reach your site over HTTPS only, closing the first-request gap.
HTTP Strict Transport Security tells browsers to use HTTPS for your domain for a stated period, so a first plain-HTTP request cannot be intercepted before the redirect happens. It is one response header. Add it only once HTTPS works everywhere, because a browser that has seen it will refuse HTTP until the max-age expires.
Why It Matters
Without HSTS, the very first request a visitor makes can be plain HTTP, and that is the request an attacker on the same network wants. Around 46% of audited sites do not send it.
How to Fix
Confirm HTTPS is complete
Start with a short max-age
Add includeSubDomains deliberately
Consider preload last
Code Fix
textcurl -sI https://example.com | grep -i strict-transport
(no output)Strict-Transport-Security: max-age=31536000; includeSubDomainsPlatform-Specific Instructions
Set it in the server config or at the CDN, not in PHP, so it is present on static assets too.
Add it in the headers() function, or at the proxy that terminates TLS.
Fixed that one.
Now find the rest.
A free audit ranks every issue on your site by the score points it costs — and links each one straight to its guide.
Run a free audit