I am trying to have two different store views with different themes but has the same catalog and settings.

default store view: website.co.uk second store view should have: migrate.website.co.uk enter image description here

Both the store views share the same website and store. it is only the front end which changes.

I have created a sub domain of the main domain I have copied .htaccess and index.php from website.co.uk to migrate.website.co.uk and modified index.php file as below:

$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'migrate';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');


$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\Framework\App\Http');


I have also added two lines at the start of htaccess file:

SetEnvIf Host .migrate.website.co.uk. MAGE_RUN_CODE=migrate SetEnvIf Host .migrate.website.co.uk. MAGE_RUN_TYPE=store

when check the migrate.website.co.uk it shows me a blank page with 500 error. what is wrong in the code?


I wouldn't recommend modifying the index.php.

This is a core file, meaning it'll simply get overwritten the next time you update Magento.

Since you're using .htaccess files I'm assuming you run apache.

In that case, you can use a virtual host configuration to share the website's files in the same directory:

<VirtualHost *:80>
    ServerName          website.co.uk
    ServerAlias         "www.website.co.uk"
    DocumentRoot        /path/to/your/magento2/
    SetEnv MAGE_RUN_CODE "default"
    SetEnv MAGE_RUN_TYPE "store"

<VirtualHost *:80>
    ServerName          migrate.website.co.uk
    DocumentRoot        /path/to/your/magento2/
    SetEnv MAGE_RUN_CODE "migrate"
    SetEnv MAGE_RUN_TYPE "store"

do you mean I still need to copy both index.php and .htaccess into subdomain directory and configure the virtual host's file?

I am using plesk and have created the subdomain, my virtual hosts file looks like below: I have two files under my sites-available: 000-default.conf default-ssl.conf

i will have to edit both default and ssl conf files. port 7080 and 7081.

what if i am using website.co.uk/newweb/ as my second store by creating a new folder under magento root. can i just place the environment variables on htaccess file on website.co.uk ? like below:

SetEnvIf Host .newstore. MAGE_RUN_CODE=newweb

SetEnvIf Host .newstore. MAGE_RUN_TYPE=store

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.