? domain_default_source.patch
Index: domain.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.admin.inc,v
retrieving revision 1.4
diff -u -p -r1.4 domain.admin.inc
--- domain.admin.inc	8 Jun 2008 16:24:14 -0000	1.4
+++ domain.admin.inc	10 Jun 2008 15:56:38 -0000
@@ -274,6 +274,21 @@ function domain_configure_form($form_sta
       This feature requires custom_url_rewrite_outbound() to be installed.')
   );
 
+  $options = array('-1' => t('Do not change domain'));
+  foreach (domain_domains() as $data) {
+    // The domain must be valid.
+    if ($data['valid']) {
+      $options[$data['domain_id']] = $data['sitename'];
+    }
+  }
+  $form['domain_advanced']['domain_default_source'] = array(
+    '#type' => 'select',
+    '#title' => t('Default source domain'),
+    '#options' => $options,
+    '#default_value' => variable_get('domain_default_source', 0),
+    '#description' => t('When rewriting urls, nodes assigned to all affiliates will be sent to this domain.'),
+  );
+
   $form['domain_advanced']['domain_www'] = array(
     '#type' => 'radios',
     '#title' => t('WWW prefix handling'),
Index: settings_custom_url.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/settings_custom_url.inc,v
retrieving revision 1.6
diff -u -p -r1.6 settings_custom_url.inc
--- settings_custom_url.inc	8 Jun 2008 16:24:14 -0000	1.6
+++ settings_custom_url.inc	10 Jun 2008 15:56:38 -0000
@@ -59,7 +59,7 @@ function custom_url_rewrite_outbound(&$p
       }
       // This path has matched a node id, so it may need to be rewritten.
       if ($nid) {
-        $root = domain_default();
+        $root = domain_lookup(variable_get('domain_default_source', 0));
         // Remove redundancy from the domain_site check.
         if (!isset($domain_site[$nid])) {
           // If this check works, we don't need to rewrite the path unless SEO rules demand it.
@@ -88,8 +88,8 @@ function custom_url_rewrite_outbound(&$p
           }
         }
         // If strict SEO rules are enabled, we set "all affiliate" links to the root domain.
-        // Only needed if we are not on the root domain.
-        else if ($seo && $_domain['domain_id'] != $root['domain_id']) {
+        // Only needed if we are not on the default source domain.
+        else if ($root != -1 && $seo && $_domain['domain_id'] != $root['domain_id']) {
           $options['absolute'] = TRUE;
           // In this case, the $base_url cannot have a trailing slash
           $options['base_url'] = rtrim($root['path'], '/');
