Auto redirect http site url to https in cpanel

cpanel, http, https, ssl, ssl-certificate

Solution

I added the following lines of code in the index page of the site

if($_SERVER["HTTPS"] != "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}

Then the site url redirected to https link

Problem

Redirect the site url http to https..for this i upload .htaccess file in my cpanl public_html root directory.the code of the file as ``` RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://sitename.in/$1 [R,L] ``` After i hosted this file also it's not redirecting my site to https protocol

Original source