Created
June 20, 2018 15:48
-
-
Save a1phanumeric/42e295e2b36c0febbed71d17ca3c43d7 to your computer and use it in GitHub Desktop.
PHP redirect to HTTPS if htaccess if giving you bare grief
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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