Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stevesmename/3714899 to your computer and use it in GitHub Desktop.
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
$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