Submitting WordPress Site to HSTS Preload List

Getting your Trinity Audio player ready...
Reading Time: < 1 minute

If you run a website, it will be more secure if you enable HSTS Preload correctly and submit it to a Google property known as https://hstspreload.org/. I tried some plugins, but they added validation errors. I prefer not using a plugin if there’s another way to solve the problem. This is the quickest method, so give it a try if you tried the above test/submission and your domain failed.

Netmagellan (this site) fails the HSTS Preload test.
Netmagellan (this site) fails the HSTS Preload test.

Edit the .htaccess File

Two entries are required in this file that lives in your website’s root folder. I added them after the # END WordPress line. The first entry adds the HSTS header. The next entry makes an HTTP request redirect HTTPS before anything else.

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

#Redirection code starts

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Redirection code Ends

Check the Site Again

That was a successful submission.

Successful submission of this website.
Successful submission of this website.

Mastodon