Skip to content

Instantly share code, notes, and snippets.

@sluc23
Created November 22, 2016 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sluc23/d30c59ab835c81b2a22cd77ace364b2c to your computer and use it in GitHub Desktop.
Save sluc23/d30c59ab835c81b2a22cd77ace364b2c to your computer and use it in GitHub Desktop.
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

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