Knowledge base
1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!
Manage HSTS for a website/hosting account
This guide explains how to disable or configure HSTS for a website.
Introduction
- When HSTS is enabled for a website, the server instructs the website visitor (if their web browser is compatible) to replace all insecure links with secure links.
- Example:
http://www.domain.xyz.com/one/page/is automatically replaced withhttps://www.domain.xyz/one/page/. - After enabling an SSL certificate on a website, HSTS is configured as follows:
max-age=16000000.
Disable HSTS…
… with a CMS (WordPress, Joomla, etc.)
Include the following line in all pages generated by the CMS:
header( 'Strict-Transport-Security: max-age=0;' );For WordPress, you can, for example, add this directive to the functions.php file of your theme:
add_action( 'send_headers', 'add_header_xua' );
function add_header_xua() {
header( 'Strict-Transport-Security: max-age=0;' );
}More details on WordPress
… with a PHP site
Include the following line in all PHP pages:
header( 'Strict-Transport-Security: max-age=0;' );To do this without having to modify each PHP page of a website, you can use the auto_prepend_file directive in the .user.ini file of the website in question:
auto_prepend_file=/home/clients/xxxx/web/hsts_disable.php... with the following hsts_disable.php file:
header( 'Strict-Transport-Security: max-age=0;' );… with a website containing static content (not PHP)
… avec un site au contenu statique (non PHP)
Include this header in a .htaccess file:
# BEGIN DISABLE HSTS
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=0; includeSubDomains;"
</IfModule>
# END DISABLE HSTS
Customize HSTS
The default value can be modified in your website's PHP files using the following directive:
header( 'Strict-Transport-Security: max-age=X; includeSubdomains; preload' );(X being the desired number of seconds).
Enable HSTS for all hosted subdomains
includeSubDomains; is enabled by default, and as its name suggests, it includes subdomains in "Strict Transport Security".
When a visitor accesses an unsecure subdomain, the browser will automatically redirect to HTTPS and trigger a security error.
If this behavior is not desired, this header must be removed.
Clear the browser's HSTS cache…
… on Chrome
- In Chrome, type
chrome://net-internals/#hsts. - Enter the domain name in the text field in the "Delete domain security policies" section.
- Click the Delete button.
- Enter the domain name in the text field in the "Query HSTS" section.
- Click on the Query button.
- The response should be "
Not found".
… on Safari
- With Safari, start by closing the browser.
- Delete the
~/Library/Cookies/HSTS.plistfile. - Reopen Safari.
… on Firefox
- With Firefox, close all tabs.
- Open the Firefox menu and click on History / Show History.
- Find the page for which you want to delete the HSTS preferences.
- Right-click on one of the corresponding entries.
- Choose Forget this site.
Link to this FAQ: https://faq.infomaniak.com/2133
Has this FAQ been helpful?