Redirect HTTP to HTTPS Using .htaccess File

Modern web browsers like Google Chrome and Firefox started to show a website visitor insecure warnings on sites without SSL certificates. If your website is not running on HTTPS or does not have an SSL certificate, your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is necessary. It becomes very important to redirect from HTTP to HTTPS.
This article will explain how to redirect your website's visitors from HTTP to HTTPS. You need to have an SSL certificate installed on your hosting account or server in order for this method to remove the insecure warning from the visitor's browser while on your website.
First you need to create a .htaccess file if it does not exist or modify an existing file on your server or hosting account.

Choose one of the following ways to create/edit a .htaccess file

  • Create/Edit the htaccess file on your computer and upload it to the server or hosting account using FTP.
  • Browse your public html directory using an FTP program and create or edit the htaccess file directly using an FTP program that supports direct editing.
  • Create/Edit the htaccess file on your computer and upload it to the server using SSH or directly create and edit the file on your server using your favourite Linux text editor.
  • Using the file manager on your server's control panel, browser for the public html directory and create or edit the htaccess file directly or create / edit it on your computer and upload it.

Before making any modifications to an existing htaccess file, be sure to make a back of of the file before editing. You can easily backup the htaccess file by opening it using a text editor and copy past the content to another file or make a copy of the file and name it htaccess_backup for example.

Redirecting all web traffic from HTTP to HTTPS

Copy the following code and paste it in your htaccess file

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us