Searching...

Redirecting HTTP to HTTPS - redirect 301 .htaccess

Do you have a valid active SSL certificate on your domain but still don't see the padlock icon in the URL bar? To display the green padlock icon correctly, you need to redirect traffic from HTTP to HTTPS. In a brief guide, we'll show you how to do that.

In the document root, locate the file .htaccess
The document root on Hukot hosting is located in the www directory, which means the path to the .htaccess file is www/.htaccess
If .htaccess is not present in the document root, create a new empty file.

We'll start by adding the activation of the redirection module to the file.

RewriteEngine On

Next, add the following:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you want the traffic to always run on the www subdomain, add the following as well:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Alternatively, if you don't want to have www in the URL bar, add the following:

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Save the file and refresh the page.

Comments

23.03.2023 18:48:39

Jen doplním, že v mém případě se .htaccess soubor v adresáři nacházel, nicméně Filezilla ho defaultně nezobrazovala. Stačilo tedy ve Filezille v kartě "server" zaškrtnout "vynutit zobrazování skrytých souborů" a bylo po problému.

28.11.2024 13:44:36

Super, funguje to. Jednoduchý návod. Díky!

06.02.2025 19:12:13

Prosím jak se dostanu do toho document rootu? mám wordpress a ani v administraci hostingu ani WP to nikde nemohu najít

To submit comment you have to be logged-in