How do I enable HSTS?

HSTS is a protocol that indicates that a website may only be accessed via a secure connection (HTTPS) for, for example, the next six months. Therefore, always make sure an SSL certificate is installed before you start using HSTS.

At server level, we do not enable HSTS by default. That would mean that every website that has ever used a certificate would have to keep using that certificate. And that is exactly what HSTS is for: once a website has been visited with an HTTPS connection one time, that same browser will no longer accept an unsecured connection afterwards. The browser remembers this check for six months.

Do you want to enable HSTS yourself? You can do this easily by adding the following line to the .htaccess file in the root folder (preferably at the top):

Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS

Via internet.nl you can immediately check whether the setup was successful.

Related articles