How to redirect websites from http to https

In this guide, we will learn about SSL redirection, Force HTTPS  & Redirection through cPanel.

Why need to switch to HTTPS?

  • SSL certificate ensures that the Transferring data between two systems is secure or secure to visit.
  • The server/browser determines that SSL is assigned by the recognized Authority certificate Providers.
  • SSL today is a TLS (Transfer Layer Security).

SSL is defied as two categorized way

  • Validation Methods
  • Types of domains they will secure. (Single Domain, Wildcard, Multi-Domain)

Here are Several Methods to make your website HTTP to HTTPS:

  1. Redirect HTTP to HTTPS via cPanel
  2. Redirecting with Apache
  3. Redirecting with Nigex
  4. www to non-www Redirection
  5. Redirection through Wordpress Plugin (If you have Wordpress Website).

SSL should be installed on your control panel else it will show an SSL error or a Non-secure site So make sure SSL is installed on your control panel or from the hosting end.

Redirect HTTP to HTTPS via cPanel

  • First, log in to your cPanel
  • Go to the Domain Section & click on The 'Domains' Tab as per shown in the below screenshots.

Https Cpanel Redirection

  • Now you will see the 'Force HTTPS Redirects' Option. Also, check the below screenshots.

Force HTTPS Redirects

Now enable it.

Force https redirect ON

A success message will appear.

Redirecting with Apache

We can add the redirection code with very easier steps as Control Panels like Plesk & cPanel Control Panel allow us to make changes via .htaccess code.

Here are the steps to create or edit .htaccess files.

  • Login to your cPanel & Go to Filemanager then Public_html Directory. Also, check the attachments for the references.

cPanel Filemanager

cpanel filemanager public_html

  • Click on the setting tab (Top right sidebar) & select ' show hidden files. (If the .httaccess file still not showing then you can create a .htaccess file, check the top left sidebar).

.htaccess files edit & create

  • Now, Select the 'SHOW HIDDEN FILES' options & save.

Show hidden files

  • Now you will see the .htaccess file, select the file & right-click on it to edit the files.

.htacees file edit option

.htaccess editor

Paste this code to redirect your website HTTP to HTTPS.

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

If you have wordpress website then Also pur this code below.

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

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress


Redirecting with Nigex

If you are using the Nigex server then you can redirect HTTP to HTTPS by adding a few lines.
Here is the below code.

server {
    listen 80;
    server_name mdb.test www.mdb.test;
    return 301 https://mdb.test$request_uri;
}

Put your domain name instead of example.com.



WWW to Non-WWW Redirection

Use this code to redirect the WWW website to Non-WWW URL

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

WWW & Non-WWW to HTTPS WWW Redirection

If you have a website with www & non-www but not redirecting to HTTPS WWW like HTTPS://WWW then use this code

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

Redirection through Wordpress Plugin

To change Wordpress website URL HTTP to HTTPS using Wordpress Plugin.

  • Log in to your Wordpress Dashboard.
  • Go to Plugins & Click on 'Add new Plugin'
  • Search this ' Really Simple SSL' in the Search Box.
  • Install & Activate it.
  • Now go to settings & click on SSL.

Wordpress website http to https via SSL plugin

Now Click on 'ACTIVATE SSL'

ACTIVATE SSL

  • Go to 'SSL Settings' & Enable all the options shown in the below screenshots.

SSL Settings

  • Enable all the options then go to the bottom & save the changes.

Enable all the options

  • Save & Continue.

Save & continues SSL changes

New Task will open, Only you have to repeat the task, Again enable all the features & save it.

Congrats, SSL HTTP to HTTPS redirection process is finished.