Did you know?
Apache's "Header set" skips error pages; security headers like HSTS need "Header always set".
Use Header always set for HSTS and other security headers; add Header unset to drop a proxied backend's copy.
- Web servers
- Applies to Apache 2.4
- Last checked
Explained
Apache keeps two lists of response headers: one for successful responses and one that is always sent, including on errors and on redirects Apache generates itself. Header set only writes to the first list, so a 404 page goes out without the header:
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
The two lists also explain duplicate headers behind ProxyPass: a backend’s own HSTS header lands in the “success” list, so Header always set doesn’t replace it. Add Header unset Strict-Transport-Security to drop the backend’s copy.
Learn more
- How to Enable HSTS in Apache (Safe Setup and Preload) Full guide · Updated Nov 2026
