You can follow any of the three methods mentioned below for redirecting your website from HTTP to HTTPS-

Method 1: Using a .htaccess file

You can use the following code and edit the .htaccessfile for moving from HTTP to HTTPS-

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Usually, the websites often use an HTTP protocol as the default protocol for handling all the critical information. Still, with https, you get various security and other benefits for your website.

Method 2: Using a PHP function

You can also use the following .php function for redirecting your website. You just need to call the function in the right place from where you wish to get the redirection.

< ?php

function redirectTohttps() {

if($_SERVER[‘HTTPS’]!=”on”) {

$redirect= “https://”.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];

header(“Location:$redirect”); } }

?>

Method 3: Using an HTML Meta Tag

The methods discussed above are sufficient enough for making a move to HTTP from HTTPS. Using an HTML Tag might not be that effective as compared to the previous two. Still, you can use it if you fail to use the “mod rewrite.”

Make sure to add the following to your web page header-

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

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

How to Migrate the Database from MS SQL to MySQL?

There are several companies that prefer migrating their database from MS SQL to MySQL. It…

How to Change the Listening Port for Remote Desktop?

Remote Desktop features in Microsoft Windows XP Professional can be used to connect to your…

How to Install cURL on Windows and Linux

In this article, we will provide a comprehensive guide on how to install and run…