Linux: Force Website from HTTP to HTTPS using htaccess

Recently web browsers will show a warning sign if your website is not secure with HTTPS encryption.
If you are hosted in Linux and users visit your website with HTTP protocol, even though you have HTTPS the website will appear as HTTP with the warning sign.

You may create a file or modify your existing htaccess (dotHTACCESS, there is a dot symbol infront of HTACCESS) file inside your website's root folder or PUBLIC_HTML folder.
Paste the following two lines of code in the beginning of your htaccess file, you can do this in the File Manager inside cPanel (if htaccess is hidden, click on the settings icon on the top right and enable show all files).

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  • 5 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

What is SSL?

SSL stands for Secure Socket Layer is the standard security technology developed by Netscape...

Can I transfer my SSL certificate to you?

If you already have the SSL certificate, you can send the backup file (.pfx format) of the...

DirectAdmin: Install SSL certificate from Let's Encrypt

Please follow the steps below to install SSL certificate from Let's Encrypt in DirectAdmin...

cPanel: Check SSL certificate status

SSL certificate is essential nowadays to boost users confidence when visiting a site.On your...

Website Shows Mixed Contents Warning (http & https)

Nowadays, it is recommended for users to enable SSL on their websites.However, on some cases, the...