How to redirect your website from HTTP to HTTPS ?

Among other recent updates, Google has revealed that one of the factors that influence their search engines would be the presence of an SSL certificate on the website (HTTPS connection). This basically means that properly secured websites would naturally gain more trust in the search engine results. Even before those news, the SSL protection was still a vital part of ones effort to secure the delicate info of their users, especially for businesses like online shops, merchants and everyone accepting any kind of personal and billing details from their visitors.

Converting your website from HTTP to HTTPS can be worrying for some, especially if you haven’t done it before. So here are 3 easy ways on how to easily make the change, without any negative effects:

1. Through a PHP function

Before you choose this path, first make sure if the SSL is already installed on the server. This can easily be seen through the defined HTTPS server variable. If it returns with an ON value, this means that the SSL is installed. From there on, the redirection is made through this code:

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

 

2. Through the .htaccess file

You need to locate your .htaccess in the File Manager of your cPanel with us. Once found, you need to Edit it and include the following code:

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

Those 3 commands basically tell your server to use mod_rewrite, to search if HTTPS is active or not, and if not active – apply the condition and rewrite the first part from HTTP to HTTPS.

3. Using a HTML meta tag 

Not the most efficient way, but if you cannot use mod_rewrite by any reason – this will work just fine. You simply need to add this line of code in your header:

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

If you need any extra assistance, you can contact us 24/7 in our Live Chat where our friendly operators would be glad to give you an additional help.

  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

What is php.ini?

Php.ini is one of the essential configuration files in PHP. When PHP starts, this is the file it...

Do you have any setup or hidden fees?

UniqueVPS does not charge any additional or hidden fees. All web hosting solutions, extra...

How many subdomains can I create with UniqueVPS?

You are free to create as many subdomains as you wish and install different site-building...

What is a subdomain?

A subdomain is a domain name that is part of a main domain. It might be a separate website with...

How to access the phpPgAdmin to manage my PostgreSQL?

Accessing phpPgAdmin is very straightforward. It is neatly located in every customers’ cPanel but...

Powered by WHMCompleteSolution