Using jQuery, I try to redirect to https like the following
webroot = webroot.replace("http","https");
window.location.href = webroot+"/processpayment";
This is not working in Live but works well in Dev environment.
The other Option I tried is redirecting in the back end code (PHP). There on load of the page (processpayment/index.php) , I called the function
http_redirect_https();
The function does the following
function http_redirect_https(){
if ($_SERVER["HTTPS"] != "on")
{
header("HTTP/1.1 301 Moved Permanently"); // Optional.
header("Location: https://{$_SERVER["SERVER_NAME"]}{$_SERVER["REQUEST_URI"]}");
exit(0); // Ensure that no other code is parsed.
}
}
But this threw an error - Too many redirects trying to open the page.
I am stuck. can you please help?