What Is HSTS and Why Does Your Website Need It?
HTTP Strict Transport Security (HSTS) forces browsers to always use HTTPS for your domain, preventing protocol downgrade attacks and mixed-content issues.
ProfitTool Team
Security & Dev
The Problem HSTS Solves
Even after you install an SSL certificate and redirect all HTTP traffic to HTTPS, there is a window of vulnerability on the very first connection. If a user types http://yoursite.com or clicks an HTTP link, their browser sends an initial unencrypted request before the server has a chance to redirect them. A man-in-the-middle attacker on the same network can intercept and modify that first request — this is called an SSL stripping attack.
HSTS eliminates this window by instructing browsers to never make an HTTP request to your domain in the first place.
How HSTS Works
When a browser receives a response with the HSTS header:
Strict-Transport-Security: max-age=31536000; includeSubDomainsIt records the policy and, for the next max-age seconds (one year in this example), automatically upgrades all requests to your domain from HTTP to HTTPS before sending them. The HTTP request never leaves the browser.
The Preload List
For maximum protection, you can submit your domain to the HSTS preload list — a list hardcoded into Chrome, Firefox, Safari and Edge. Preloaded domains are enforced as HTTPS-only even on the very first visit, before the browser has ever seen your HSTS header.
Requirements for preload:
- Serve a valid certificate
- Redirect all HTTP to HTTPS
- Serve HSTS on all subdomains (
includeSubDomainsrequired) max-ageof at least 31536000 (one year)- Include the
preloaddirective
Submit at hstspreload.org.
What Not to Do
- Do not set HSTS on a domain where you are not fully committed to HTTPS — removing it after the fact is difficult because browsers cache the policy.
- Do not use a very long
max-ageuntil you have tested HTTPS thoroughly on all subdomains. - Start with a short
max-age(e.g. 3600), verify everything works, then increase to one year.
Check whether your site's HSTS header is configured correctly with our Security Headers Checker.
ProfitTool Team
Security & DevWritten and maintained by the ProfitTool team. Where an article references a ProfitTool utility, the behaviour described is the behaviour of the tool on this site — you can open it and check the output yourself.
More from the Knowledge Hub
What Is the HSTS Preload List and How Do You Get On It?
The HSTS preload list ships inside browsers, so HTTPS is enforced before the first visit. The submission requirements, and why removal takes months.
Privacy & SecurityHow to Check SSL Certificate Expiry: 5 Methods
An expired SSL certificate blocks all users with a hard browser warning. Here are five ways to check certificate expiry before it becomes a problem.
Privacy & SecurityHTTP Security Headers Explained: HSTS, CSP, X-Frame-Options and More
HTTP security headers are directives your web server sends to browsers to prevent common attacks like XSS, clickjacking and protocol downgrade. Here is what each one does.