Skip to content

Instantly share code, notes, and snippets.

@owen2
Created July 18, 2012 18:33
Show Gist options
  • Save owen2/3137949 to your computer and use it in GitHub Desktop.
Save owen2/3137949 to your computer and use it in GitHub Desktop.
Enforce ssl automatically in PHP
if ($_SERVER['HTTPS'] != "on") {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment