# HSTS: An HTTP redirect leaves the first request unencrypted.

- Rating: Do it now (Check today. Visitors or their data may already be affected.)
- Action: Send HSTS over HTTPS so returning browsers go straight to the secure address.
- Added: 2026-12-03
- Updated: 2026-12-03
- Web page: https://tldrtls.com/hsts/

## What to do

When someone follows an HTTP link, the browser sends a request before your server can redirect it. After the browser receives a Strict-Transport-Security (HSTS) header over HTTPS, it upgrades future requests itself.

This example covers the domain and all its subdomains. Use `includeSubDomains` only when every subdomain can serve HTTPS.

```text
Strict-Transport-Security: max-age=63072000; includeSubDomains
```

It tells browsers to use HTTPS for your site for the next two years, even if a link or a typed address says `http://`.

Redirect `http://example.com` to `https://example.com` on the same hostname first, and only then anywhere else. If the first hop goes straight to a different host, the browser never sees the header for the name the visitor typed.

## How to check

```sh
curl -sI https://example.com | grep -i strict-transport-security
```

Or with weeb ([get weeb](https://tldrtls.com/checking-tools.md)):

```sh
weeb probe example.com --fix
```

Look at the `HTTPS redirect` and `Strict-Transport-Security` lines.

## How to fix it

Start with a short `max-age`, such as 300 seconds, check nothing breaks, then raise it.

`includeSubDomains` covers every name under your domain. Be sure all of them serve HTTPS before you add it.

### Preloading

Adding `preload` and submitting your domain to [hstspreload.org](https://hstspreload.org/) bakes the rule into browsers, which closes the gap on the very first visit. Getting off the list again is slow, so do it only when every subdomain is on HTTPS for good.

## Sources

1. [RFC 6797: HTTP Strict Transport Security](https://www.rfc-editor.org/rfc/rfc6797.html) (fetched 2026-12-03)
2. [HSTS preload list: submission requirements and removal](https://hstspreload.org/) (fetched 2026-12-03)
3. [weeb: terminal HTTP client with a site probe](https://github.com/klobucar/weeb) (fetched 2026-12-03)

## Changelog

- 2026-12-03: Explained the first visit and the subdomain setting.
- 2026-12-03: First version.
