Skip to content

Instantly share code, notes, and snippets.

@alexharris
Last active March 6, 2018 19:46
Show Gist options
  • Save alexharris/a44f4602de42192a571e053c5c8828cf to your computer and use it in GitHub Desktop.
Save alexharris/a44f4602de42192a571e053c5c8828cf to your computer and use it in GitHub Desktop.
$subdomains = ['atlanta', 'berkeley', 'columbus'];
foreach ($subdomains as $subdomain) {
if (isset($_ENV['PANTHEON_ENVIRONMENT']) &&
($_SERVER['HTTP_HOST'] == $subdomain . '.yoursite.com') &&
// Check if Drupal or WordPress is running via command line
(php_sapi_name() != "cli")) {
$newurl = 'http://www.yoursite.com/' . $subdomain . '/'. $_SERVER['REQUEST_URI'];
header('HTTP/1.0 301 Moved Permanently');
header("Location: $newurl");
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment