Enabling HSTS
HSTS (HTTP Strict Transport Security) tells your visitors' browsers that your website can only be reached over a secure connection (HTTPS). From then on the browser no longer uses a plain HTTP connection, not even when someone types http://. This protects against man-in-the-middle attacks. You first enable HSTS with a short period (5 minutes) and only extend it once everything works.
Before you start
- Your website works fully over HTTPS, with a valid SSL certificate. See Setting up a free SSL certificate.
- All scripts, stylesheets, images and other resources on your website load over
https://. - Your website redirects
http://tohttps://: a browser only adopts HSTS after a visit over HTTPS. In DirectAdmin this is Force SSL with https redirect on the same page as below; in Plesk it is the option Redirect visitors from HTTP to HTTPS via a SEO friendly 301 redirect in the hosting settings of your domain.
Enter a domain name, such as yourdomain.nl.
This value doesn’t fit here. An example: whs1.
Web Hosting (DirectAdmin)
Also for Reseller Hosting.
- Log in to DirectAdmin via Single Sign-On from Mijn xYnta, or at
https://yourdomain.nl:2222. - Under Account Manager, click Domains and then
yourdomain.nl. The Modify Domain screen opens. - Under HSTS, tick Enable HTTP strict transport security.
- At Max-age for HSTS header, choose 5 minutes, and leave Include subdomains off.
- Click MODIFY.
Note: DirectAdmin adds preload to the header itself: max-age=300; preload. At 5 minutes this has no effect; if you later extend it to a year with Include subdomains, the header meets the requirements of the preload list (see below).
WordPress Hosting (Plesk)
- Log in to Plesk at
https://whs1.srvnl.nl:8443. You can find your server name in How can I find the server name of my hosting package? - On the left, click Files and then the httpdocs folder.
- If there is no
.htaccessyet, click the blue plus button, choose Create File, enter.htaccessunder File name and click OK. - Click the name
.htaccess. The file opens in the Code Editor. - Put
Header set Strict-Transport-Security "max-age=300"at the top of the file, on a line of its own. If there is a block# BEGIN WordPress…# END WordPress, put the line above that block: WordPress rewrites everything in between. - Click Save.
Then: extending the period
Extend the period
DirectAdmin: at Max-age for HSTS header, choose 1 year and click MODIFY. Plesk: change
max-age=300in the line tomax-age=31536000(one year) and click Save.Only include subdomains if they all have HTTPS
If all your subdomains (including
mail.,webmail.and any you created yourself) work over HTTPS, you can include them. DirectAdmin: tick Include subdomains. Plesk: make itmax-age=31536000; includeSubDomains.
Tips
- Test HSTS on a subdomain first, and write down what you change so you can find it again later.
- Switching HSTS off does not work immediately: a browser that saw the header earlier keeps requiring HTTPS until the old period is over. If you use the line in
.htaccess, first setmax-age=0and leave that line in place until the old period has expired.
HSTS preload list
The HSTS preload list is a list built into browsers such as Chrome, Firefox and Safari. A domain name on that list always opens over HTTPS, even on the very first visit: the browser skips the HTTP request. Getting off the list is difficult, so only submit your domain name after thorough testing, when all your subdomains have HTTPS and you intend to use HTTPS permanently. The header must then contain at least one year, all subdomains and preload:
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"More information and submission: hstspreload.org.
Related articles
Thank you for your feedback.

