Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v retrieving revision 1.280 diff -u -p -r1.280 CHANGELOG.txt --- CHANGELOG.txt 1 Oct 2008 00:27:29 -0000 1.280 +++ CHANGELOG.txt 9 Oct 2008 17:20:07 -0000 @@ -52,6 +52,8 @@ Drupal 7.0, xxxx-xx-xx (development vers and memory improvements. - Theme system: * Converted the 'bluemarine' theme to a tableless layout. +- Added aliased multi-site support: + * Added support for mapping domain names to sites directories. Drupal 6.0, 2008-02-13 ---------------------- Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.230 diff -u -p -r1.230 bootstrap.inc --- includes/bootstrap.inc 6 Oct 2008 22:40:20 -0000 1.230 +++ includes/bootstrap.inc 9 Oct 2008 17:20:08 -0000 @@ -272,6 +272,21 @@ function timer_stop($name) { * * 13. $confdir/default * + * If a file named sites.php is present in the $confdir, it will be loaded + * prior to scanning for directories. It should define an associative array + * named $sites, which maps domains to directories. For example: + * + * $sites = array( + * 'dev.example.com' => 'example.com', + * 'mymachine/example' => 'example.com' + * ); + * + * The above array will cause Drupal to look for a directory named + * "example.com" in the sites directory whenever a request comes from + * "example.com", "dev.example.com", or "mymachine/example". That is useful + * on development servers, where the domain name may not be the same as the + * domain of the live server. + * * @param $require_settings * Only configuration directories with an existing settings.php file * will be recognized. Defaults to TRUE. During initial installation, @@ -290,12 +305,22 @@ function conf_path($require_settings = T return $conf; } - $confdir = 'sites'; + $confdir = DRUPAL_ROOT . '/sites'; + + $sites = array(); + if (file_exists($confdir . '/sites.php')) { + // This will overwrite $sites with the desired mappings. + include($confdir . '/sites.php'); + } + $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']); $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.'))))); for ($i = count($uri) - 1; $i > 0; $i--) { for ($j = count($server); $j > 0; $j--) { $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i)); + if (isset($sites[$dir]) && file_exists("$confdir/{$sites[$dir]}")) { + $dir = $sites[$dir]; + } if (file_exists("$confdir/$dir/settings.php") || (!$require_settings && file_exists("$confdir/$dir"))) { $conf = "$confdir/$dir"; return $conf;