PHP Script Switch Page to HTTPS
Here is a quick php script that you can add to the top of any page you want to be secure. Obviously, it requires you actually have an SSL Certificate all set up on your domain first.
<?php if(empty($_SERVER['HTTPS'])) { // If not, redirect $newurl = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; header("location: $newurl"); exit(); } ?>



Found this page on Google by typing “switch to htpps script.”
We were actually looking for a script that created a link on the page that it is on.
It works great when tested. Our only problem is that the page has Adsense
so there is a warning. If we hack the Adsense code, we risk Google dropping
us from their Adsense.