Good afternoon!
I read an article about the friendship of ModX and LS , and decided to ask a question that I myself can’t decide in ModX how to implement the logic of Revo depending on the current subdomain of the main site?
I see on pro-cent.ru that the name of the city is placed in the subdomain (http://kaliningrad.pro-cent.ru/). Does ModX help in handling this, or is everything done with your hands and your code?
<?php // switch($modx->context->key){ case 'web': break; default: return; } // 3- , if(preg_match('/([^\.]+)\.[^\.]+\.[^\.]+$/',$_SERVER['HTTP_HOST'], $match)){ if($ctx = $modx->getObject('modContext', $match[1])){ // if($ctx->prepare()) { // MODx- // , API $modx->getOption(); // , [[++site_name]], // $modx->config = array_merge($modx->config, $ctx->config); } } } // // - , , // - // if(!$host && (!$host = $modx->config['mainHost'])) { // print " ".$modx->context->key; return; } // print $host; $redir_host = ''; $redir_url = ''; // switch($modx->event->name){ case 'OnPageNotFound': break; case 'OnHandleRequest': break; default: ; } // if(!preg_match('/^'.$host.'$/i', $_SERVER['HTTP_HOST'])){ $redir_host = $host; $redir_url = $_SERVER['REQUEST_URI']; } // , 301- ( ) if($redir_host || $redir_url){ $params = array(); $redir_url ? $params['url'] = $redir_url : ""; $redir_host ? $params['hostl'] = $redir_host : ""; $modx->runSnippet('redirect', $params); }
Source: https://habr.com/ru/post/151751/
All Articles