Created
November 22, 2016 11:40
-
-
Save sluc23/d30c59ab835c81b2a22cd77ace364b2c to your computer and use it in GitHub Desktop.
LE SSL redirection
This file contains 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 # local settings.php | |
$request_type = ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'SSL' : 'NONSSL'; | |
if ($request_type != "SSL" && isset($_SERVER['HTTP_USER_AGENT']) && !preg_match('<ignore_url>',$_SERVER['REQUEST_URI'])){ | |
header('X-Accel-Expires: 1'); | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); | |
header("Connection: close"); | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try to replace the first line with:
$request_type = ($_SERVER['SERVER_PORT'] == '443') ? 'SSL' : 'NONSSL';