HSTS

HTTP Strict Transport Security (HSTS) is a security mechanism that you can use for HTTPS connections. It's good to help protect you from downgrade attacks, in which you're forced to downgrade your security and you cannot make an encrypted connection using TLS. HSTS can also defend your site against cookie hijacking. To prevent these security issues, a server can tell the user's browser to only accept encrypted connections for a domain (HTTPS) and to never accept insecure interactions that use only HTTP. The server communicates to the user agent using an HTTP header field, which is called "Strict-Transort-Security". And it defines a time period (max-age) when the user-agent can securely access the server.

To set the HSTS header, you must include the following in the .htaccess file:

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

Experts also recommend that you still set up HTTP to HTTPS redirects, even if you are using HSTS. "Why is this necessary?" you might ask, "Doesn't HSTS do this by default?" No, HSTS will only implement an HTTP to HTTPS redirect if the visitor has been to the site already using HTTPS. To set up the HTTPS redirect, create a .htaccess file with the following content.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Header set Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload"
  • 0 Uživatelům pomohlo
Byla tato odpověď nápomocná?

Související články

Cache lifetime

How can I set the cache lifetime for a website? The module mod_expires is installed on Apache...

CGI scripts

Using CGI scripts File your CGI scripts in the "public_html" folder of your account. Make sure...

Content compression

Activate compression mod_deflate (for Gzip) is installed on our servers. You can activate it by...

CORS

Cross-origin resource sharing (CORS) is a mechanism that allows web applications to access...

Directory index

How can I protect a folder from being viewed in the browser? In the menu, go to "Manage...

Powered by WHMCompleteSolution