We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45063
    • 40 Posts
    I have a multilingual site with multiple context. Every context is initializing via HTTP_HOST switch.

    switch ($_SERVER['HTTP_HOST']) {  
    
    	case 'domain.de':
    	$modx->initialize('de');
    	break;
    
    	case 'domain.com':
    	$modx->initialize('com');
    	break;
    }


    The thing is, I need one more separate context that initializing by entering 'domain.com/en/'. I tried alter the switch this way:

    switch ($_SERVER['HTTP_HOST']) {  
    
    	case 'domain.de':
    	$modx->initialize('de');
    	break;
    
    	case 'domain.com':
    	if($_SERVER['REQUEST_URI'] == /en/) {
    		$modx->initialize('com-en');
    	}
    	else {
    		$modx->initialize('com');
    	}
    	break;
    }


    But no luck. I managed to load the context, to see it, but every URL pointing back to default 'com' context. Any suggestions?
    There is probably some Rewrite Rules must be applied. I read this article, but it assumes you have only preudo-subfolder context.