--- multidomain.module.orig	Thu Jul 12 10:49:18 2007
+++ multidomain.module	Fri Jul 13 16:42:51 2007
@@ -527,7 +527,8 @@
 
   $domains = variable_get('multidomain_sites', array());
   $protocol = ( $_SERVER['HTTPS'] ) ? 'https://' : 'http://' ;
-  if ($domain = $domains[$protocol . $_SERVER['HTTP_HOST']]) {
+  if ($domain = $domains[$protocol . str_replace("www.", "", $_SERVER['HTTP_HOST'])]) {
     // Determine if we are currently on the home page.
     $front = drupal_is_front_page();
 
@@ -578,13 +579,15 @@
         return $return;
       // If we are are rewriting all but the default, return if this is the default.
       case MULTIDOMAIN_TAXONOMY_REWRITE_NON_DEFAULT:
-        if ($current == $default) {
+        if (str_replace("www.", "",$current) == $default) {
           return $return;
         }
         // Fall through.
       case MULTIDOMAIN_TAXONOMY_REWRITE_ALL:
         // Determine if we are on a registered domain.
-        if ($domain = $domains[$current]) {
+        if ($domain = $domains[str_replace("www.", "", $current)]) {
           if (isset($domain['tid'])) {
             $return['join'] = 'INNER JOIN {term_node} tn ON tn.nid = '. $primary_table .'.nid';
             $return['where'] = 'tn.tid = '. $domain['tid'];
@@ -646,7 +649,7 @@
     }
     $base = $force_default ? $default : NULL;
     foreach ($domains as $domain => $info) {
-      $source = $type == 'alias' ? $path : drupal_lookup_path($path);
+      $source = $type == 'alias' ? $real_path : drupal_lookup_path($path);
       $arg = explode('/', $source);
       // Determine if this is a node.
       $is_node = ($arg[0] == 'node' && is_numeric($arg[1]));
@@ -691,7 +703,8 @@
       }
     }
     if ($type == 'alias') {
-      if (($protocol . $_SERVER['HTTP_HOST'] != $base) && !is_null($base) && (strpos($path, '://') === FALSE)) {
+      if (($protocol . str_replace("www.", "", $_SERVER['HTTP_HOST']) != $base) && !is_null($base) && (strpos($path, '://') === FALSE)) {
         $path = $base .'/'. (!$clean_url ? '?q=' : '') . $path;
       }
     }
