Created
May 13, 2012 00:04
-
-
Save ssx/2669784 to your computer and use it in GitHub Desktop.
Redirect to SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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