Forked from kellybell/settings.php redirect for Pantheon sites
Created
September 13, 2012 15:01
-
-
Save stevesmename/3714899 to your computer and use it in GitHub Desktop.
Pantheon settings.php URL normalizing code - rewrites www.sitename.com (and othersubdomains.sitename.com) to sitename.com
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
$primary_domain = 'mountainwest.aaa.com'; | |
$primary_schema = 'http://'; | |
$live_subdomain = 'www.'; | |
$test_subdomain = 'test.'; | |
$live_domain = $live_subdomain . $primary_domain; | |
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && | |
$_SERVER['PANTHEON_ENVIRONMENT'] === 'test') { | |
$base_url = $primary_schema . $test_subdomain . $primary_domain; | |
} | |
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && | |
$_SERVER['PANTHEON_ENVIRONMENT'] === 'live') { | |
if($_SERVER['HTTP_HOST'] == $live_domain) { | |
$base_url = $primary_schema . $live_domain; | |
} | |
else { | |
header('HTTP/1.0 301 Moved Permanently'); | |
header('Location: '. $primary_schema . $live_domain . $_SERVER['REQUEST_URI']); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment