how to redirect site 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.
Comments
Post a Comment