0

I'm trying to setup glgtest.tk and lmtest.tk

I have setup two new stores in magento 2 (glg and lm):

enter image description here

Base urls are set correctly Magento back end (also checked database).

Index.php:

switch($_SERVER['HTTP_HOST']) {
    case 'lmtest.tk':
        $mageRunCode = 'lm';
        $mageRunType = 'website';
    break;
    case 'glgtest.tk':
        $mageRunCode = 'glg';
        $mageRunType = 'website';
    break;
    case 'magento-399087-1256529.cloudwaysapps.com':
        $mageRunCode = 'base';
        $mageRunType = 'website';
    break;
}
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = $mageRunCode;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = $mageRunType;
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
$bootstrap->run($app);

Htaccess:

SetEnvIf Host www\.lmtest\.tk MAGE_RUN_CODE=lm
SetEnvIf Host www\.lmtest\.tk MAGE_RUN_TYPE=website
SetEnvIf Host www\.glgtest\.tk MAGE_RUN_CODE=glg
SetEnvIf Host www\.glgtest\.tk MAGE_RUN_TYPE=website

RewriteCond %{HTTP_HOST} ^(.*)lmtest\.tk
RewriteRule .* – [E=MAGE_RUN_CODE:lm]
RewriteCond %{HTTP_HOST} ^(.*)lmtest\.tk
RewriteRule .* – [E=MAGE_RUN_TYPE:website]

RewriteCond %{HTTP_HOST} ^(.*)glgtest\.tk
RewriteRule .* – [E=MAGE_RUN_CODE:glg]
RewriteCond %{HTTP_HOST} ^(.*)glgtest\.tk
RewriteRule .* – [E=MAGE_RUN_TYPE:website]

Currently both domains are redirecting to my default domain (magento-399087-1256529.cloudwaysapps.com) with cloudways.

Can anyone shed any light on why this isn't working?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.