.htaccess » Enable HSTS Preload for a WordPress website

Enable HSTS Preload for a WordPress website

To enable HSTS Preload on a WordPress website (https://hstspreload.org/?domain=wpxss.com) you need to add the following code snippet in the .htaccess file:

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

If you have access to the server settings *(You are using a VPS or DEDICATED server) then you can enable it server-wide for all domains by adding the snippet to the /etc/apache2/conf.d/includes/pre_main_global.conf file

pre main global - Enable HSTS Preload for a WordPress website
nano /etc/apache2/conf.d/includes/pre_main_global.conf

TIP: If you are using Apache and not LiteSpeed WebServer then you also need to restart the service for the new configuration to take effect.


If you are using Cloudflare, simply enable HTTP Strict Transport Security (HSTS) under SSL/TLS > Edge Certificates.

enable hsts on cloudflare 1024x615 - Enable HSTS Preload for a WordPress website
Enable HSTS on Cloudflare

and on the next popup set:

2023 06 24 13 23 1 - Enable HSTS Preload for a WordPress website
HSTS Settings on Cloudflare

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended