Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LE SSL redirection
<?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;
}
@omega8cc
Copy link

omega8cc commented Nov 22, 2016

Try to replace the first line with:

$request_type = ($_SERVER['SERVER_PORT'] == '443') ? 'SSL' : 'NONSSL';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment