Created
August 6, 2017 20:48
-
-
Save dherbold/78891a7789b491a292de057ffeffb7e6 to your computer and use it in GitHub Desktop.
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
/ Redirect all traffic to non-www. For example yoursite.com | |
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && | |
($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') && | |
// Check if Drupal or WordPress is running via command line | |
(php_sapi_name() != "cli")) { | |
if ($_SERVER['HTTP_HOST'] == 'www.youwebsite.com') { | |
header('HTTP/1.0 301 Moved Permanently'); | |
header('Location: https://yourwebsite.com'. $_SERVER['REQUEST_URI']); | |
exit(); | |
} | |
} | |
// Require HTTPS. | |
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && | |
($_SERVER['HTTPS'] === 'OFF') && | |
// Check if Drupal or WordPress is running via command line | |
(php_sapi_name() != "cli")) { | |
if (!isset($_SERVER['HTTP_X_SSL']) || | |
(isset($_SERVER['HTTP_X_SSL']) && $_SERVER['HTTP_X_SSL'] != 'ON')) { | |
header('HTTP/1.0 301 Moved Permanently'); | |
header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment