Skip to content

Instantly share code, notes, and snippets.

@steveobbayi
Created November 1, 2019 08:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save steveobbayi/04ec25a6d2633d366756cbc3501c6950 to your computer and use it in GitHub Desktop.
<?php
if (
$_SERVER['HTTP_HOST'] != 'localhost' && // optionally disable on localhost
!(
( $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1 ) ||
( isset($_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' )
)
)
{
$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