Set values in an entry point script
If necessary, copy the existing index.php
entry point script for your website or store view and add to it the following:
<?php
$params = $_SERVER;
$params[MagentoStoreModelStoreManager::PARAM_RUN_CODE] = '<code>';
$params[MagentoStoreModelStoreManager::PARAM_RUN_TYPE] = '{store|website}';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params);
$app = $bootstrap->createApplication('MagentoFrameworkAppHttp');
$bootstrap->run($app);
?>
Set values in .htaccess
This section discusses how to set values for MAGE_RUN_TYPE
and MAGE_RUN_CODE
using Apache server variables SetEnvIf
or RewriteCond
. If you’re not sure what environment variable to use, consult a network administrator.
SetEnvIf example
Add the following after RewriteEngine on
in .htaccess
:
SetEnvIf Host .*<your domain>.* MAGE_RUN_CODE=<code>
SetEnvIf Host .*<your domain>.* MAGE_RUN_TYPE={store|website}
For example, to use a website with the code frenchsite.example.com
:
SetEnvIf Host .*example.com.* MAGE_RUN_CODE=frenchsite.example.com
SetEnvIf Host .*example.com.* MAGE_RUN_TYPE=website
RewriteCond example
Add code similar to the following after RewriteBase /magento/
in .htaccess
:
RewriteCond %{HTTP_HOST} ^(.*)<your domain><domain suffix>
RewriteRule .* – [E=MAGE_RUN_CODE:<code>]
RewriteCond %{HTTP_HOST} ^(.*)<your domain><domain suffix>
RewriteRule .* – [E=MAGE_RUN_TYPE:{store|website}]
For example, to use a website with the code frenchsite.example.com
:
RewriteCond %{HTTP_HOST} ^(.*)example.com
RewriteRule .* – [E=MAGE_RUN_CODE:frenchsite.example.com]
RewriteCond %{HTTP_HOST} ^(.*)example.com
RewriteRule .* – [E=MAGE_RUN_TYPE:website]