Domain Redirect

1. What does it do?

This is a contributed module that sends a permanent redirect if someone tries to access a page that is not available on the current domain. For it to work you need to clear the page cache after enabling it.

You can define a domain-setting in wich order domains should be selected when the node can be redirected to more then one domain. By default if the node is requested in one of the defined affiliates it will not be redirected. This module also can respect the settings of module domain source.

When configured the module can create a canonical link in the header. This is usefull when you have one or more pages accessible from more then  one domain. For more information about canonical links see: googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html.

2. Configuration options

You have to create a domain selection table with the selection order of domains.

  1. If a node is published to more then one domain you can chose to wich domain the node is redirected to. There are two options:
    • if domain source is installed you can chose to always redirect to this domain, even if the current domain is a valid affiliate;
    • If the current domain is not a valid affiliate the first valid affilate is selected from the domain selection table.
  2. Create a canonical link. The first valid affiliate in the domain selection table will be the base node for the link (i.e. no link will be present in the node in this domain). The same node in all other domains will have the canonical link.
    You can select the node types to be excluded from canonical links.

3. API function

There is one api function to create a canonical link for a given path and base domain. This api will respect all configuration settings. This is created to be able to set canonical links for system or custom paths like contact.

domain_redirect_create_canonical_link($path, $domain_id = -1, $query = NULL)
$path / $query: path and query to create a link for
$domain-id: the base domain_id to link to. If it is not the current domain a canonical link will be created.

4. CVS account

We have requested a CVS account, so we hope to publish this module in the near future on drupal.org.

5. Downloads

We have the Drupal 5 version of domain-redirect running in five sites now and more to come in Drupal 6. Up till today we didn’t test the D6 version ourselves.

Please inform us when you have any problem. You can drop a comment after loggin in.

Download Drupal 5 version.

Download Drupal 6 version.

Download Drupal 7 version.

6. Test

You can test the redirects. Test1 will redirect to domain1.drupalhandboek.nl. Test2 will redirect to domain2.drupalhandboek.nl. No canonical links are created: these pages are only available in the given affiliates.

This page is available in domain1.drupalhandboek.nl and domain2.drupalhandboek.nl. The domain1.drupalhandboek.nl page has no canonical link, domain2.drupalhandboek.nl does have the link.