Created
June 3, 2019 06:55
-
-
Save qwertik17/fe1e5912bb55428b2f74e257fb34eec0 to your computer and use it in GitHub Desktop.
redirect form multidomain for modx revo
This file contains hidden or 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 | |
$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