Skip to content

Instantly share code, notes, and snippets.

@kythin
Created July 23, 2013 23:22
Show Gist options
  • Save kythin/6067003 to your computer and use it in GitHub Desktop.
Save kythin/6067003 to your computer and use it in GitHub Desktop.
Force a page to use HTTPS using this function.
function forceSSL() {
if($_SERVER["HTTPS"] != "on") {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment