Skip to content

Instantly share code, notes, and snippets.

@delineas
Last active February 22, 2016 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delineas/c7ff244c87ee84c6ec3d to your computer and use it in GitHub Desktop.
Save delineas/c7ff244c87ee84c6ec3d to your computer and use it in GitHub Desktop.
Drupal Redirect Node Domain Access
<?php
function mymodule_init() {
if(arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) && $node = node_load(arg(1))) {
$current_domain = domain_get_domain();
$domains = domain_get_node_domains($node->nid);
if (!in_array($current_domain['domain_id'], $domains['domain_id'])) {
$values = array_values($node->domains);
$sourceDomain = array_shift($values);
$sourceDomain2 = domain_lookup($sourceDomain);
//domain_goto($sourceDomain2);
if ($sourceDomain2['domain_id'] > 0 && $current_domain['domain_id'] != $sourceDomain2['domain_id']) {
$path = domain_get_uri($sourceDomain2);
drupal_goto($path, array(), 301);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment