Last active
August 29, 2015 14:11
-
-
Save bjornbjorn/b3cb640b97dc85592c3a to your computer and use it in GitHub Desktop.
secure http -> https redirect in master config (EE)
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
/** | |
* Force HTTPS on prod & staging. This functionality was previously in the .htaccess'es but we moved | |
* it here to ease multiple environment development. | |
*/ | |
if(FORCE_HTTPS && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "")){ | |
$redirect_url = filter_var("https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], FILTER_VALIDATE_URL); | |
if($redirect_url) { | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: $redirect_url"); | |
die(); | |
} else { | |
die('Please use HTTPS equivalent of this URL.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment