Skip to content

Instantly share code, notes, and snippets.

@heronyang
Created October 25, 2014 08:15
Show Gist options
  • Save heronyang/599074cdbd3afda38d78 to your computer and use it in GitHub Desktop.
Save heronyang/599074cdbd3afda38d78 to your computer and use it in GitHub Desktop.
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
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