Last active
October 11, 2016 19:29
-
-
Save mkorkmaz/733e88afc41007dde79e9efffdf51529 to your computer and use it in GitHub Desktop.
Redirect non-secure requests to ssl enabled url for Cloudflare Flexible SSL enabled domains using PHP.
This file contains hidden or 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
<?php | |
if (empty($_SERVER["HTTP_CF_VISITOR"]) || $_SERVER["HTTP_CF_VISITOR"] != '{"scheme":"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