Skip to content

Instantly share code, notes, and snippets.

@heronyang
Created October 25, 2014 08:16
Show Gist options
  • Save heronyang/21493894f5eed6bdccd4 to your computer and use it in GitHub Desktop.
Save heronyang/21493894f5eed6bdccd4 to your computer and use it in GitHub Desktop.
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "http") {
if(!headers_sent()) {
header("Status: 301 Moved Permanently");
header(sprintf(
'Location: https://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
));
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment