dsince1984 Posted March 9, 2011 Share Posted March 9, 2011 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! Quote Link to comment Share on other sites More sharing options...
btherl Posted March 9, 2011 Share Posted March 9, 2011 Your server guy should be fixing this. Do you get the same error when the script doesn't do any redirects at all? Quote Link to comment Share on other sites More sharing options...
dsince1984 Posted March 11, 2011 Author Share Posted March 11, 2011 Yeah, I figured it out. Our server guy was requiring the encryption so it didn't care what I had on a page. If the original URL wasn't https it would complain. Once he just applied SSL to the page but unchecked the box requiring it, it started working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.