This is probably really stupid but I can’t figure out why this isn’t working. So I have this code on my page.
[php]<?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;
}
?>[/php]
When I was just trying this code out it worked and redirected to https. However, once we 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 and these HTTPS redirects work for everyone else, so how come on my site it won’t read the code before telling me I need to have a https:// url? Thanks for any insight!