This is probably some silly mistake but I can't figure out why this code isn't working. I put this at the top of my php page:
<?php
$https_url = 'https://somesite.com';
if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'off' )
{
header('location: ' . $https_url);
exit;
}
else if ( !isset( $_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] == 443 )
{
header('location: ' . $https_url);
exit;
}
?>
When I was just trying this code out it worked and redirected to https. No errors no infinite loops...it worked perfectly. However, once our server guy actually applied the SSL to the page, the code stopped working and I get the error "The page must be viewed over a secure location." It throws the error before it processes anything on that page. I found the code online on another help forum and it worked for everyone else, so what am I doing wrong? I also tried a different version of the code that also works for everyone else but got the same error. Thanks for your help!