Skip to content

Instantly share code, notes, and snippets.

@ssx
Created May 13, 2012 00:04
Show Gist options
  • Save ssx/2669784 to your computer and use it in GitHub Desktop.
Save ssx/2669784 to your computer and use it in GitHub Desktop.
Redirect to SSL
<?php
// If your web server is accepting HTTPS connections directly, then the
// request will be directly on port 443. If we aren't on port 443, then
// it's possible we're using a proxy such as Varnish, in which case, most
// modern proxy servers send the HTTP_X_SSL_CIPHER header through with the
// request. You could also test for a custom header from your proxy too.
if (($_SERVER["SERVER_PORT"] != 443) &&
(empty($_SERVER["HTTP_X_SSL_CIPHER"])))
{
Header("Location: https://".$_SERVER["SERVER_NAME"].
$_SERVER["REQUEST_URI"]);
exit(0);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment