agentsiteaudit · Checks · Security

HSTS: make browsers always use the secure version of your site

Test your website free

Runs all 69 checks, including this one. 5 free audits a day.

HSTS (HTTP Strict Transport Security) is a header that tells browsers: "only ever visit this site over HTTPS". Once a browser has seen it, it will not load the insecure http:// version again, even if a link or a network tries to send it there.

Our check passes when HSTS is set with a max-age of at least 180 days (15552000 seconds), warns when it is shorter, and fails when it is missing on HTTPS.

In our November 2026 study of businesses selling to AI agents, 42% of the 1,190 websites we checked had no HSTS header, or one with a short max-age. See the full study.

Why it matters

Without HSTS, the first visit can still start on http://, where it can be intercepted on public Wi-Fi before the redirect to HTTPS happens. HSTS closes that gap for returning visitors.

What our check looks for

Check ID security.hsts.present · Security · Medium priority

How to fix it

Apache or cPanel (.htaccess)

<IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=31536000" env=HTTPS
</IfModule>

Only add this once your whole site works on HTTPS. Add includeSubDomains only when every subdomain also has HTTPS.

Nginx

add_header Strict-Transport-Security "max-age=31536000" always;

Put it in the HTTPS (port 443) server block only.

Cloudflare

SSL/TLS > Edge Certificates > HTTP Strict Transport Security

Turn it on with a max-age of at least 6 months. Read Cloudflare's warning about subdomains first.

Test it

curl -sI https://www.example.co.uk/ | grep -i strict-transport

You should see the header with the max-age you set.

Common mistakes

Related checks

Written by Derek Moore, who builds and runs websites for small UK businesses. Last checked 30 October 2026.