Skip to content

Instantly share code, notes, and snippets.

@froboy
Created November 15, 2017 15:34
Show Gist options
  • Save froboy/c35732abe4cd1f41729f92d8557762ef to your computer and use it in GitHub Desktop.
Save froboy/c35732abe4cd1f41729f92d8557762ef to your computer and use it in GitHub Desktop.
If you have a Drupal multisite with predictable hostnames, use this to keep your sites.php lean.
<?php
$sites['somecustomsitename.com'] = 'somecustomsite.com';
if (strpos($_SERVER['HTTP_HOST'], "-ra") != FALSE) // somesite-ra.com
{
$sites[$_SERVER['HTTP_HOST']] = // Cut out -ra and rewrite to somesite.com
str_replace("-ra", "", $_SERVER['HTTP_HOST']);
}
if (strpos($_SERVER['HTTP_HOST'], "-dev") != FALSE) // somesite-dev.com
{
$sites[$_SERVER['HTTP_HOST']] = // Cut out -sites and rewrite to somesite.com
str_replace("-dev", "", $_SERVER['HTTP_HOST']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment