How to Fix a Missing HSTS Header (Strict-Transport-Security)
Your homepage is served without a Strict-Transport-Security (HSTS) response header, so browsers are not told to always use HTTPS for your domain. By the end of this guide you will have added HSTS with a max-age of at least one year on your server, CDN or platform, and confirmed that the header appears on the HTTPS response for your homepage.

Why it matters
com or follows an old http:// link makes a first request over plain HTTP before your redirect kicks in. On public Wi-Fi, that request can be intercepted and the visitor downgraded to an insecure connection (SSL stripping). HSTS tells the browser to rewrite every future request to HTTPS before it leaves the device.
That closes this gap and removes one redirect hop for returning visitors. It is not a direct ranking factor, but it is a standard security baseline. Missing security headers also lower trust scores in audits and security scanners.
What you need
Step-by-step fix
Check the headers your homepage sends today
Run curl against the exact HTTPS homepage URL and look for a strict-transport-security line. Also check the HTTP version to confirm it redirects to HTTPS with a 301. The audit only looks at the homepage response, but you should apply the header site-wide.
If a CDN sits in front of your origin, the header you see here is the one browsers receive.
curl -sI https://example.com/ | grep -i -E '^(HTTP|strict-transport-security)' curl -sI http://example.com/ | grep -i -E '^(HTTP|location)'
Audit subdomains before using includeSubDomains
The includeSubDomains directive forces HTTPS on every subdomain of the host that sends it. com`. If any subdomain has no valid certificate, browsers will refuse to load it until max-age expires.
List your DNS records and test each subdomain over HTTPS. If any can't serve HTTPS yet, leave includeSubDomains out for now.
for h in www shop blog mail staging; do echo -n "$h: "; curl -s -o /dev/null -w '%{http_code}\n' https://$h.example.com/; doneAdd the header on Nginx
Put add_header inside the server { } block that listens on 443. Browsers ignore HSTS sent over plain HTTP, so the port 80 block doesn't need it. The always flag makes Nginx send the header on error and redirect responses too.
Watch for inheritance: if a location block defines its own add_header, it drops all server-level add_header lines. In that case, repeat the HSTS line inside that location.
server {
listen 443 ssl;
http2 on;
server_name example.com www.example.com;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# ... rest of your config
}
# then test and reload:
# sudo nginx -t && sudo systemctl reload nginxOr add the header on Apache
Enable mod_headers and add the directive to the HTTPS <VirtualHost *:443> block. On shared hosting, add it to .htaccess in your web root instead. Use Header always set so the header is also sent on redirects and error pages.
# In <VirtualHost *:443> or .htaccess
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>
# Debian/Ubuntu: sudo a2enmod headers && sudo apachectl configtest && sudo systemctl reload apache2Or set it in Next.js / Vercel config
js. js. json instead.
Deploy, then test the production domain, not a preview URL.
// next.config.js
module.exports = {
async headers() {
return [
{
source: '/(.*)',
headers: [
{ key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' }
]
}
];
}
};Decide whether to add preload (optional)
Adding preload and submitting your domain at hstspreload.org gets it hardcoded into browsers, which protects even the very first visit. Requirements:
- max-age of at least 31536000
- includeSubDomains
- a valid HTTPS redirect
Removal from the preload list takes months. Only do this once every subdomain is permanently on HTTPS. It's not needed to pass this check.
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Purge caches and verify the live header
Clear your CDN and page cache so the homepage is served fresh. Then re-run curl against the HTTPS homepage. You should see one strict-transport-security line with max-age=31536000 or higher.
Re-run the audit to confirm the check now passes.
curl -sI https://example.com/ | grep -i strict-transport-security # expected: strict-transport-security: max-age=31536000; includeSubDomains
Platform-specific notes
Cloudflare
Go to SSL/TLS → Edge Certificates → HTTP Strict Transport Security (HSTS) → Enable HSTS. Acknowledge the warning, set Max Age Header to 12 months, and choose whether to apply HSTS to subdomains and add preload. Leave No-Sniff as you prefer. Your SSL/TLS encryption mode must be Full or Full (strict), and Always Use HTTPS should be on.
WordPress
WordPress core does not send HSTS. On Apache hosts, add the Header directive to .htaccess. On Nginx hosts, ask your host or use their panel; some managed hosts offer an HSTS toggle. You can also send it from PHP with add_action('send_headers', fn() => is_ssl() && header('Strict-Transport-Security: max-age=31536000; includeSubDomains'));. However, full-page caches or a CDN may serve cached pages without running PHP, so a server- or CDN-level header is more reliable.
Shopify
You cannot edit server headers on Shopify. Shopify sends HSTS on storefronts with SSL enabled, but with a shorter max-age than one year. If the audit reports it missing, go to Settings → Domains and confirm the SSL certificate is active and the domain is primary. If your custom domain is proxied through Cloudflare, add HSTS there.
Webflow
Open Site settings → Publishing → Advanced publishing options and turn on Enable HSTS. Republish the site. Webflow manages the max-age value. If you need a specific value or includeSubDomains control, put Cloudflare in front of the site and set the header there.
Wix / Squarespace
Both platforms manage HTTPS and response headers for you, and you cannot add custom headers. Make sure HTTPS/SSL is switched on in the site's domain or SSL settings. If HSTS is still absent, the only workaround is a proxy/CDN you control, such as Cloudflare.
Check that it worked
✅ How to verify
- Run curl -sI https://example.com/ and confirm a single strict-transport-security header with max-age=31536000 or higher.
- In Chrome, open DevTools → Network, reload the homepage, click the document request and check Response Headers for Strict-Transport-Security.
- Visit chrome://net-internals/#hsts, enter example.com under Query HSTS/PKP domain and confirm a dynamic_sts entry appears after visiting the site over HTTPS.
- Re-run the site audit and confirm the HSTS header check passes.
⚠️ Common mistakes
- Adding the header only to the port 80 (HTTP) server block. Browsers ignore HSTS received over HTTP, and the audit reads the HTTPS homepage.
- Using includeSubDomains while a subdomain like mail.example.com or an old staging host has no valid certificate, which makes it unreachable for up to a year.
- Defining add_header inside an Nginx location block, which silently cancels the server-level HSTS line for those URLs, or omitting the always flag.
- Submitting to the preload list before every subdomain is ready. Getting removed takes months and affects all major browsers.
Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.
Check my site freeFAQ
What max-age should I use for HSTS?
Use at least 31536000 seconds (one year). That's the common recommendation and the minimum for preload eligibility. Many sites use 63072000 (two years). When testing, you can start with 300 seconds and raise it once you've confirmed nothing breaks.
Does HSTS improve SEO rankings?
Not directly. Google uses HTTPS as a lightweight signal, and HSTS reinforces it by removing the HTTP-to-HTTPS redirect for returning visitors. Its main value is security, preventing protocol downgrade attacks, and passing security audits.
How do I undo HSTS if something breaks?
Send the header with max-age=0 over HTTPS. Each browser that sees it will forget the policy. Browsers that never revisit keep the old policy until it expires, which is why a short max-age during testing is safer. Preloaded domains require a removal request at hstspreload.org.
Do I need HSTS if I already redirect HTTP to HTTPS?
Yes. A redirect still lets the first HTTP request go out unencrypted, where it can be intercepted. HSTS makes the browser switch to HTTPS before sending anything, so the insecure request never happens on later visits.
How to Fix www vs non-www Duplicate Hostnames with 301s
How to Fix SSL Certificate Expiry and Trust Errors
How to Fix a Missing robots.txt File (Step-by-Step)
How to Fix Mixed Content Warnings on an HTTPS Website
How to Fix robots.txt Blocking CSS, JS and Key Pages
How to Fix the HTTP to HTTPS Redirect (301) on Your Site