Last active
February 22, 2016 11:40
-
-
Save delineas/c7ff244c87ee84c6ec3d to your computer and use it in GitHub Desktop.
Drupal Redirect Node Domain Access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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