Redirects http to https connection (For Entire Website)

Hi, https is necessary for every website to be secure or to get approval from Adsense also. https Secure connection also used in transaction websites.

Different between HTTP and https connection

HTTP stands for “hypertext transfer protocol” and in https “s” stands for secure socket layer. Most of the website in the world using HTTP connection which necessary for every website, But https connection makes your website secure for transactions and also green padlock icon makes the trust on visitors.

There are four ways to apply https redirection on any website

Be Sure You have to an SSL Certificate

Using .htaccess Redirection

First of all, you have a valid SSL certificate then you have to force your website to apply https redirection using .htaccess in the file manger of cpanel. (You have to enable show hidden file). Then paste the given code.

RewriteEngine OnRewriteCond %{HTTPS} offRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Using PHP Redirection

Php is another easier way to force a website to a secure connection. Go to your file manager in cpanel, open the index.php file then paste the given code at the top of page.

function redirectTohttps() {
    if ($_SERVER['HTTPS'] != ”on”) {
        $redirect = “https: //”.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];header(“Location:$redirect”); } } ?>

Using Meta Redirection

If you using an HTML based website, we can force our website to secure connection using meta tags redirection. Go to File manager in cpanel, then open the index.html file and paste the code below the <head> tag.

< meta http-equiv="Refresh" content="0;URL=https://www.example.com" />

Using WordPress Plugin

If you are using a WordPress blog it is easy to force your website to secure connection using a free plugin. The most popular https redirection Plugins are given below:

Thanks for Visiting, if you have any doubts, problems with articles or copyright you can contact us.

2 thoughts on “Redirects http to https connection (For Entire Website)”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.