<?php if($modx->context->get('key') != "mgr"){ //grab the current domain from the http_host option switch ($modx->getOption('http_host')) { case 'en': //switch the context $modx->switchContext('Englisch'); //set the cultureKey $modx->setOption('cultureKey', 'en'); break; case 'ru': //switch the context $modx->switchContext('Russisch'); //set the cultureKey $modx->setOption('cultureKey', 'ru'); break; default: case 'e': //switch the context $modx->switchContext('Spanisch'); //set the cultureKey $modx->setOption('cultureKey', 'es'); break; default: // Set the default language/context here $modx->switchContext('web'); $modx->setOption('cultureKey', 'de'); break; } }
<?php if($modx->context->get('key') != "mgr") { /* Определяем текущий язык в cultureKey */ switch ($_REQUEST['cultureKey']) { /* Переключаем контекст */ case 'en': $modx->switchContext('Englisch'); break; case 'ru': $modx->switchContext('Russisch'); break; case 'es': $modx->switchContext('Spanisch'); break; /* Устанавливаем контекст по умолчанию */ default: $modx->switchContext('web'); break; } /* Очищаем GET-параметр чтобы не допустить появлении ссылки вида cultureKey=xy при генерации URL других компонентов */ unset($_GET['cultureKey']); }
RewriteRule ^(en|nl|de)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
RewriteRule ^(en|nl|de)/(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
RewriteEngine On RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en|ru|es)/favicon.ico$ favicon.ico [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en|ru|es)/assets(.*)$ assets$2 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(de|en|ru|es)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA] # The Friendly URLs part # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# The Friendly URLs part # redirect original domain.name to domain.name/defaultLang RewriteCond %{HTTP_HOST} . RewriteRule ^$ en/ [R=301,L] #https://github.com/chsmedien/XRouting/issues/19#issuecomment-173992718 RewriteCond %{REQUEST_URI} ^/(en|de|id|in|jp|nl|ru|th|zh)$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]