Domain Access force node redirect to proper domain Using Domain Access with Drupal 6, I am encountering an issue in the following scenario:

I set up a node published to a sub site, say:

subsite.com/node-x


If I browse to:

mainsite.com/node-x 


I would like it to redirect to:

subsite.com/node-x


However, it just renders the content on the main site domain (which the search engines would pick up as duplicate content).

Any idea how I can configure the sites to redirect to the site on which the node is published? I attempted to use Global Redirect to redirect from the main site to the full url  on the sub site but Drupal told me that I was redirecting something to itself. Are web server redirects my only option?
There is a special module for that: https://www.drupal.org/project/domain_path_rewrite.

The idea is to check the request path before the page load and to make a redirect to the proper domain if needed. Something like:

/**
 * Implements hook_init().
 */
function domain_path_rewrite_init() {
  if ($domain_path = _domain_path_rewrite_domain_path(current_path())) {
    global $_domain;

    if (!($_domain['domain_id'] == $domain_path['domain_id'] &amp;&amp; request_path() == $domain_path['path'])) {
      drupal_goto($domain_path['url'], array(), 301);
    }
  }
}