Skip to content

Instantly share code, notes, and snippets.

@qwertik17
Created June 3, 2019 06:55
Show Gist options
  • Save qwertik17/fe1e5912bb55428b2f74e257fb34eec0 to your computer and use it in GitHub Desktop.
Save qwertik17/fe1e5912bb55428b2f74e257fb34eec0 to your computer and use it in GitHub Desktop.
redirect form multidomain for modx revo
<?php
$parent_id = $modx->resource->parent;
if ($parent_id == 0) {
return;
}
$parents = $modx->getParentIds($modx->resource->id, 10, array('context' => 'web'));
$parents = array_reverse($parents);
if ($parents[1] == 21) {
if ($cur_catalog = $modx->getObject('modResource',$parents[3])) {
if ($only_moskow = $cur_catalog->getTVvalue('only_moskow')){
if ($only_moskow == 1) {
$domain = 'nedorogo-kuhni.ru';
$cur_domain = $_SERVER['HTTP_HOST'];
if ($cur_domain == $domain) { //Если домены совпадают, то выходим из скрипта
return;
} else {
$url = $modx->makeUrl($parents[2]);
$modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
}
};
}
}
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment