ST Hosting Manual

Our manual

Force HTTPS using .htaccess

All the basics of forcing HTTPS with .htaccess

Often the question is posed how to use .htaccess HTTPS that forces you to use HTTPS encryption as an end-user.
This is possible with a simple script, which you can insert arbitrarily.
You simply create a new file in the htdocs or httpdocs directory and name it .htaccess after that you use a rewrite rule.

The file should contain the following content:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* %{SERVER_NAME}%{REQUEST_URI} [R=301,L]

Of course, the rule can be changed however you want depending on your own wishes.