Skip to content

How do you enable HTTP Strict Transport Security (HSTS)?

HTTP Strict Transport Security (HSTS) tells browsers to only communicate with your website over HTTPS. This prevents protocol downgrade attacks and cookie hijacking by ensuring all connections use SSL/TLS.

Add the following to your site’s .htaccess file:

Header always set Strict-Transport-Security "max-age=31536000"

This tells browsers to only use HTTPS when connecting to your site for one year (31,536,000 seconds).

To apply HSTS to all subdomains as well:

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

To submit your domain to the HSTS preload list (which hardcodes the HTTPS requirement into browsers), use:

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