Most of ecommerce websites, online shopping websites and secure websites uses SSL or https connection to make the between server and client secure and effective.
Here is solution for you to redirect http to https (ssl) by two ways one by using PHP and one by using .htaccess.

SSl (secure socket layer) or https version of a website makes it more secure and reliable for users to use.

But one of the main problems for new web designers after installing SSL in their server is that even after installing ssl in their server when users type in their browser the same http version of website is shown to user.

Below are given two solutions to the problem for you; one by using PHP and another by using HTACCESS.

1> Redirect http to https using PHP:
You can simply add the following function in your website and call it when ever you need to redirect to http request to your site to https.

function redirectToHTTPS()
$redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

2> Redirect http to https using .htaccess.
You can simply add the following code in the .htaccess file of the root directory of your website and all the user request with http will be redirect to https of your site.

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Popular Searches: