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 Users Found This Useful
Was this answer helpful?

Related Articles

Website Shows Mixed Contents Warning (http & https)

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

Windows: Installing SSL certificate in IIS

SSL certificate need to be installed on the server where the CSR was generated, this is crucial...

Windows: Force website to HTTPS using web.config

Latest web browser will show your website as "insecure" when a visitor visit your site via the...

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...

What is SSL?

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