I want to redirect my www.mysite.in to https://www.mysite.in, I tried all possible code of php in index.php as below mentioned but still unable to redirect....I am not getting exact solution. Please help me regarding.
<?php
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != '') {
header("location: https://".$_SERVER['HTTP_HOST']);
} else {
header("location: http://".$_SERVER['HTTP_HOST'])
}?>
------------------------------------OR---------------------------------------
<?php
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == ""){
$redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header("HTTP/1.1 301 Moved Permanently");
header("Location: $redirect");
}
?>
------------------------------------OR----------------------------------------
<?php
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "")
{
$HTTPURI = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("HTTP/1.1 301 Moved Permanently"); // Optional.
header("Location: $HTTPURI");
exit(0);
}
?>
touch filenameon the server; or by executing a number of commands in PHP to generate/create a file (file_put_contents, fwrite, etc.)