Did anyone use Babel together with XRouting and get it to work lately?
I have a multilanguage site using contexts with URLs such as mydomain.se, mydomain.se/en/, mydomain.se/de/ etc for the various languages and it works fine. I’ve used Babel and some edits in the .htaccess file to set it up.
Now I also want to add a new context with a completely different domain, like mydomain2.se. So I’ve installed XRouting which as I understand it is supposed to work. However, upon doing this my language links stop working. I tried both with my edited .htaccess and the default one that comes with MODX.
Is XRouting not compatible with the current version of MODX and Babel, or am I doing something wrong? What does .htaccess need to look like for it to work?
MODX 2.8.2
Babel 3.0.0
XRouting 1.4.1 (I also found and tried 1.5.1)
Hi @robcarey, that description looks like what I did to get the languages working (/en, /de etc). However, for an additional context with its own domain I can find any instructions?
You shouldn’t have to make any changes to the default .htaccess file for XRouting to work.
Have you tried troubleshooting the problem with XRouting? When you set the system setting xrouting.allow_debug_info to Yes and append &xrouting-debug=1 to the url, then you should see what the plugin does.
What did you use before to switch the context inside MODx? A custom plugin? Is this plugin still active (and maybe interferes with XRouting)?
This is the .htaccess I’ve been using together with Babel when just having one domain and multilanguage sites in subfolders (/en, /de etc), which worked fine. I don’t think I used anything other plugins to route to the language folders but I’ll take another look just in case.
Ah, I actually found a gateway plugin I’d used for the routing:
<?php
if($modx->context->get('key') != "mgr"){
/* grab the current langauge from the cultureKey request var */
switch ($_REQUEST['cultureKey']) {
case 'en':
/* switch the context */
$modx->switchContext('English');
break;
case 'de':
/* switch the context */
$modx->switchContext('Deutch');
break;
case 'fr':
/* switch the context */
$modx->switchContext('Francais');
break;
case 'nl':
/* switch the context */
$modx->switchContext('Nederlands');
break;
default:
/* Set the default context here */
$modx->switchContext('web');
break;
}
/* unset GET var to avoid
* appending cultureKey=xy to URLs by other components */
unset($_GET['cultureKey']);
}
I’ve disabled it now and cleared the cache but I still get error 404 on the language folders
Are there http_host and base_url settings for all your contexts?
Maybe instead of using XRouting you could also just change your custom plugin.
Read the value of $_SERVER['HTTP_HOST'] and then switch to the appropriate context ($modx->switchContext()) if it matches your new domain.
Ooooooh I actually didn’t have http_host set for the languages! Now I get both the right languages AND the correct context on the new domain
Some assets don’t load correctly though, and I don’t get diverted automatically to https anymore. I guess that’s a different topic but if you have some advise that would be greatly appreciated
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.