Add the below as a snippet, and include it BEFORE any output can happen on the page.
[cc lang="php"]
if($_SERVER["HTTPS"] != "on") {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
exit();
}
?>
[/cc]