Skip to content

Instantly share code, notes, and snippets.

@weednation12
Created October 16, 2017 22:29
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 weednation12/53c039e5deece2fac306c89e94174032 to your computer and use it in GitHub Desktop.
Save weednation12/53c039e5deece2fac306c89e94174032 to your computer and use it in GitHub Desktop.
PHP HTTP -> HTTPS
<?php
if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment