Only in domain: .settings_custom_url.inc.swp
diff -urp domain_orig/domain.module domain/domain.module
--- domain_orig/domain.module	2008-04-21 00:07:17.000000000 +0200
+++ domain/domain.module	2008-05-08 11:13:25.000000000 +0200
@@ -642,6 +642,10 @@ function domain_nodeapi(&$node, $op, $a3
           }
         }
       }
+      if ($a4 === TRUE && variable_get('domain_seo_cloak',0)){
+        require_once('settings_custom_url.inc');
+        domain_seo_redirect($node);
+      }
       break;
     case 'insert':
     case 'update':
diff -urp domain_orig/domain_admin.inc domain/domain_admin.inc
--- domain_orig/domain_admin.inc	2008-03-30 22:42:12.000000000 +0200
+++ domain/domain_admin.inc	2008-05-08 10:20:52.000000000 +0200
@@ -256,6 +256,7 @@ function domain_configure_form($user_sub
     $disabled = TRUE;
     variable_set('domain_search', 0);
     variable_set('domain_seo', 0);
+    variable_set('domain_seo_cloak',0);
   }
   $form['domain_advanced']['domain_search'] = array(
     '#type' => 'radios',
@@ -277,6 +278,17 @@ function domain_configure_form($user_sub
       This feature requires the hook_url_alter() patch.')
   );
 
+  $form['domain_advanced']['domain_seo_cloak'] = array(
+    '#type' => 'radios',
+    '#title' => t('Cloaked SEO'),
+    '#disabled' => !variable_get('domain_seo', 0),
+    '#default_value' => variable_get('domain_seo_cloak',0),
+    '#options' => array(0 => t('Rewrite URLs for all user agents'), 1 => t('Rewrite URLs for search spiders only')),
+    '#description' => t('If cloak is turned on, URLs will only be rewritten for search spiders. In addition, any attempt
+      from the search spiders to access a node on the "wrong" domain will be permanently redirected - thus making sure
+      links to cloaked URLs will be indexed correctly.')
+  );
+
   $form['domain_advanced']['domain_www'] = array(
     '#type' => 'radios',
     '#title' => t('WWW prefix handling'),
diff -urp domain_orig/settings_custom_url.inc domain/settings_custom_url.inc
--- domain_orig/settings_custom_url.inc	2008-03-30 22:42:12.000000000 +0200
+++ domain/settings_custom_url.inc	2008-05-08 11:20:38.000000000 +0200
@@ -19,7 +19,7 @@ function custom_url_rewrite_outbound(&$p
   // If the domain_id is not set, then the Domain module is not active, and we cannot run this function.
   if (isset($_domain['domain_id'])) {
     // Set static variables for the node lookups, to remove redundant queries.
-    static $domain_site, $domain, $nodepaths;
+    static $nodepaths;
 
     // Store the original path for later use.
     $original_path = $path;
@@ -32,6 +32,11 @@ function custom_url_rewrite_outbound(&$p
       $skip = TRUE;
     }
 
+    // Check if we are treating search spiders differently
+    if (variable_get('domain_seo_cloak', 0) && !_spider()){
+      $skip=TRUE;
+    }
+
     // This routine only needs to be run from certain urls or if we want to
     // force all links to go to a single domain for SEO.
     // See http://drupal.org/node/195366 for the background.
@@ -61,42 +66,103 @@ 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();
-        // 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.
-          $domain_site[$nid] = db_result(db_query("SELECT grant_view FROM {node_access} WHERE nid = %d AND gid = 0 AND realm = '%s'", $nid, 'domain_site'));
-        }
-        if (!$domain_site[$nid]) {
-          // Remove rendundancy from the domain_id check.
-          if (!isset($domain[$nid])) {
-            // The Domain Source module is optional, and allows nodes to be assigned to specific domains for the
-            // purpose of this check.
-            if (module_exists('domain_source')) {
-              $source = db_result(db_query("SELECT domain_id FROM {domain_source} WHERE nid = %d", $nid));
-              $domain[$nid] = domain_lookup($source);
-            }
-            else {
-              // Load the domain data for this node -- but only take the first match.
-              $id = db_result(db_query_range("SELECT gid FROM {node_access} WHERE nid = %d AND realm = '%s' AND grant_view = 1 ORDER BY gid", $nid, 'domain_id', 0, 1));
-              $domain[$nid] = domain_lookup($id);
-            }
-          }
-          // Can we and do we need to rewrite this path?
-          if ($domain[$nid] != -1 && $domain[$nid]['domain_id'] != $_domain['domain_id']) {
-            $absolute = TRUE;
-            // In this case, the $base_url cannot have a trailing slash
-            $base_url = rtrim($domain[$nid]['path'], '/');
-          }
-        }
-        // 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']) {
-          $absolute = TRUE;
-            // In this case, the $base_url cannot have a trailing slash
-            $base_url = rtrim($root['path'], '/');
-        }
+        _domain_base_url($nid, $absolute, $base_url, $seo);
+      }
+    }
+  }
+}
+
+/**
+ * Helper func for custom_url_rewrite_outbound() and domain_seo_redirect()
+ * Returns the base url for the given node (or empty string if current domain is fine).
+ */
+function _domain_base_url($nid, &$absolute, &$base_url, $seo)
+{ 
+  global $_domain;
+  // Set static variables for the node lookups, to remove redundant queries.
+  static $domain_site, $domain;
+  
+  $root = domain_default();
+  // 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.
+    $domain_site[$nid] = db_result(db_query("SELECT grant_view FROM {node_access} WHERE nid = %d AND gid = 0 AND realm = '%s'", $nid, 'domain_site'));
+  }
+  if (!$domain_site[$nid]) {
+    // Remove rendundancy from the domain_id check.
+    if (!isset($domain[$nid])) {
+      // The Domain Source module is optional, and allows nodes to be assigned to specific domains for the
+      // purpose of this check.
+      if (module_exists('domain_source')) {
+        $source = db_result(db_query("SELECT domain_id FROM {domain_source} WHERE nid = %d", $nid));
+        $domain[$nid] = domain_lookup($source);
+      }
+      else {
+        // Load the domain data for this node -- but only take the first match.
+        $id = db_result(db_query_range("SELECT gid FROM {node_access} WHERE nid = %d AND realm = '%s' AND grant_view = 1 ORDER BY gid", $nid, 'domain_id', 0, 1));
+        $domain[$nid] = domain_lookup($id);
+      }
+    }
+    // Can we and do we need to rewrite this path?
+    if ($domain[$nid] != -1 && $domain[$nid]['domain_id'] != $_domain['domain_id']) {
+      $absolute = TRUE;
+      // In this case, the $base_url cannot have a trailing slash
+      $base_url = rtrim($domain[$nid]['path'], '/');
+    }
+  }  
+  // 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']) {
+    $absolute = TRUE;
+    // In this case, the $base_url cannot have a trailing slash
+    $base_url = rtrim($root['path'], '/');
+  }
+}
+
+/**
+ * Returns true if the user agent is a spider
+ */
+function _spider()
+{
+  static $spider=NULL;
+  if ($spider===NULL){
+    $spider=false;
+    $se_user_agents = array(
+      '-Googlebot-',
+      '-msnbot-',
+      '-Slurp-',
+      '-Ask Jeeves-',
+    );
+    foreach ($se_user_agents as $match) {
+      if (preg_match($match,$_SERVER['HTTP_USER_AGENT'])){
+        $spider=true;
+        return $spider;
       }
     }
   }
+  return $spider;
 }
+
+/**
+ * Sends a permanent redirect to search spiders, if they are accessing a node through the wrong domain
+ */
+function domain_seo_redirect(&$node)
+{
+  // Abort if the user agent ain't no spider
+  if (!_spider()) {
+    return;
+  }
+
+/*  $base_url="";
+  $absolute=NULL;*/
+  // Check if we get a base_url  (otherwise - no redirect)
+  _domain_base_url($node->nid, $absolute, $base_url, variable_get('domain_seo',0));
+  if ($base_url) {
+    if(!$node->path){
+      $node->path=ltrim($_SERVER['REQUEST_URI'],'/');  // Alternately, we may go with "node/$nid" - but this is more intuitive
+    }
+    drupal_goto("$base_url/".$node->path,NULL,NULL,301); // 301 is a permanent redirect
+  }
+}
+
+
