Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v
retrieving revision 1.253.2.38
diff -u -p -r1.253.2.38 CHANGELOG.txt
--- CHANGELOG.txt	4 Mar 2010 00:25:13 -0000	1.253.2.38
+++ CHANGELOG.txt	14 Apr 2010 22:18:13 -0000
@@ -2,6 +2,8 @@
 
 Drupal 6.17-dev, xxxx-xx-xx (development release)
 ----------------------
+- Added aliased multi-site support:
+  * Added support for mapping domain names to sites directories.
 
 Drupal 6.16, 2010-03-03
 ----------------------
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.206.2.14
diff -u -p -r1.206.2.14 bootstrap.inc
--- includes/bootstrap.inc	1 Feb 2010 16:49:14 -0000	1.206.2.14
+++ includes/bootstrap.inc	14 Apr 2010 22:18:16 -0000
@@ -228,6 +228,30 @@ 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.  It should be in the form
+ * of:
+ *
+ * $sites = array(
+ *   'The url to alias' => 'A directory within the sites directory'
+ * );
+ *
+ * For example:
+ *
+ * $sites = array(
+ *   'devexample.com' => 'example.com',
+ *   'localhost.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", "devexample.com", or "localhost/example". That is useful
+ * on development servers, where the domain name may not be the same as the
+ * domain of the live server.  Since Drupal stores file paths into the database
+ * (files, system table, etc.) this will ensure the paths are correct while
+ * accessed on development servers.
+ *
  * @param $require_settings
  *   Only configuration directories with an existing settings.php file
  *   will be recognized. Defaults to TRUE. During initial installation,
@@ -247,12 +271,22 @@ function conf_path($require_settings = T
   }
 
   $confdir = '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 (file_exists("$confdir/$dir/settings.php") || (!$require_settings && file_exists("$confdir/$dir"))) {
+      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;
       }
Index: sites/example.sites.php
===================================================================
RCS file: sites/example.sites.php
diff -N sites/example.sites.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sites/example.sites.php	14 Apr 2010 22:18:22 -0000
@@ -0,0 +1,46 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Configuration file for Drupal's multi-site directory aliasing feature.
+ *
+ * Drupal searches for an appropriate configuration directory based on the
+ * website's hostname and pathname. A detailed description of the rules for
+ * discovering the configuration directory can be found in the comment
+ * documentation in 'sites/default/default.settings.php'.
+ *
+ * This file allows you to define a set of aliases that map hostnames and
+ * pathnames to configuration directories. These aliases are loaded prior to
+ * scanning for directories, and they are exempt from the normal discovery
+ * rules. The aliases are defined in an associative array named $sites, which
+ * should look similar to the following:
+ *
+ * $sites = array(
+ *   'devexample.com' => 'example.com',
+ *   'localhost.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", "devexample.com", or "localhost/example". That is useful
+ * on development servers, where the domain name may not be the same as the
+ * domain of the live server. Since Drupal stores file paths into the database
+ * (files, system table, etc.) this will ensure the paths are correct while
+ * accessed on development servers.
+ *
+ * To use this file, copy and rename it such that its path plus filename is
+ * 'sites/sites.php'. If you don't need to use multi-site directory aliasing,
+ * then you can safely ignore this file, and Drupal will ignore it too.
+ */
+
+/**
+ * Multi-site directory aliasing:
+ *
+ * Edit the lines below to define directory aliases. Remove the leading hash
+ * signs to enable.
+ */
+#$sites = array(
+#  'devexample.com' => 'example.com',
+#  'localhost.example' => 'example.com',
+#);
