Skip to the content
Start free

No Strict-Transport-Security (HSTS) header

Without HSTS, a visitor's first request can go over plain http before your redirect, where it can be read or changed.

Medium priority Security and HTTPS

Why it matters #

Strict-Transport-Security tells browsers to use only https for your site and to upgrade any later http visit themselves, before anything is sent. Without it, a visitor who types your address without https:// first asks over plain http, and that request can be intercepted.

Browsers ignore the header when it arrives over http, so it only works once the site runs fully on https.

How to fix it #

Once every page works on https, send "Strict-Transport-Security: max-age=31536000" (one year) on https answers. Add includeSubDomains only when every subdomain works on https too.

Most hosts, CDNs and security plugins have a setting for it. Check it with the Security Headers Checker.

What it looks like, and fixed #

The problem
HTTP/2 200
content-type: text/html; charset=UTF-8
x-content-type-options: nosniff

An https answer with no Strict-Transport-Security header.

Fixed
HTTP/2 200
content-type: text/html; charset=UTF-8
x-content-type-options: nosniff
strict-transport-security: max-age=31536000

One year of HSTS. Add includeSubDomains only when every subdomain works on https.

Fix it with your AI assistant #

Paste this into ChatGPT, Claude, Gemini or your coding agent. Fill in the words in [square brackets] first. It checks before it changes anything, changes only this, and tells you how to prove it worked.

Your instruction for the AI
Help me add HSTS to [your website address], which runs on [your platform or server, e.g. WordPress on Apache, nginx, or Cloudflare in front]. A checker says https answers have no Strict-Transport-Security header, so a first visit over plain http can be intercepted before my redirect. First check: run "curl -sI https://[your domain]/" (or ask me to paste the headers) and confirm there is no HSTS header and none sent twice. Also ask me whether every page, and every subdomain, works on https. Explain what you found in plain words. Then add one header on https answers only: start with "max-age=300" to test, then raise it to "max-age=31536000". Rules: back up configuration files first, do not add includeSubDomains or preload unless I confirm every subdomain is on https, add it in one place only, and keep all other headers and redirects. Give the exact line, the file or setting it goes in, and how to reload. Finally, tell me to re-check with the URSY.com Security Headers Checker at ursy.com/security-headers-checker/.

We find the problems, and help you fix them

  1. Check Run a free tool or the full audit.
  2. Fix it with your AI Download your AI Fix Pack and drop it into ChatGPT, Claude or Gemini. A free account is enough.
  3. Re-check Come back, check again, and watch each fix turn green.

How the AI Fix Pack works, with a sample to download

Fix it on your platform #

WordPress

Many security plugins have an HSTS option. On Apache hosting you can also add Header always set Strict-Transport-Security "max-age=31536000" to .htaccess, with mod_headers on.

Your server or hosting

On nginx, add add_header Strict-Transport-Security "max-age=31536000" always; to the https server block only. On Apache, use Header always set in the https virtual host.

Your CDN (for example Cloudflare)

Cloudflare has an HSTS setting under SSL/TLS, Edge Certificates. Use it or the server, not both.

Check it is fixed #

Run the Security Headers Checker again: it should find one Strict-Transport-Security header with a max-age of at least a year once you have finished testing.

Official source #

MDN: Strict-Transport-Security

Questions #

Can HSTS lock visitors out?

If https breaks while browsers remember the rule, visitors cannot click past the warning until you fix it. Keep certificate renewal automatic, and start with a short max-age.

Should I ask for preload straight away?

No. Preload is hard to undo and covers every subdomain. Run plain HSTS for a while first, and preload only when you are sure the whole domain stays on https.

More problems in Security and HTTPS

See every problem in the library

For AI assistants and developers: Instructions for AI · Developers · How to cite URSY.com