Say you want to redirect every page on your website. There are several ways of doing this, but only one right way to do so. Doing a search will show you the same stackoverflow result. The way they say to do it (which is the lame way!) is to do this in your pages header using JS (I prefer the PHP way, if not for the hosting redirect):
<?php
//redirect to https using PHP (you can add get methods this way!)
if ($_SERVER['HTTPS'] != "on") {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit;
}
//Here you can redirect from within a script page with any variables from previous page
header("Location: " . $_SESSION['uri'] . "?yourVariable=" .$theVariable ."&anotherVar=".$nextVar."&happyID=".$theGottenHappyID."#" . $anchor);
?>
<!--redirect to https using javascript-->
<script>
//redirect to https with javascript
if (location.protocol !== "https:") {
location.protocol = "https:";}
</script>
Don't do it these ways because it will break your back button, unless you want it to be annoying, but people will then just get angry and close the page and walk away from you.
So here is the best method, and it's simple. Log in to your hosting service provider, go into your CPanel, and use an automatic redirect with the https version. So here in my example I redirect with TYPE: permament(301), DOMAINS: (don't use all, just the one you are redirecting within that website), SITE: (leave this one blank), REDIRECTS TO: https://yoursite.com
Bewm! That now makes your website redirect to https:// whenever someone types it with http:// or without any. This secures your site way better than redirecting it with refresh or javascript redirecing. Best of all, each page on your website now gets that green metal that google gives out for being good boy. OH! I forgot to mention that many host providers offer free SSL on all of your sites for free... Most of the major ones don't.