I have a multistore webshop with multiple websites and languages.

  • I upgraded from 2.3.5-p1 to 2.4.2 via composer
  • Changed the PHP-version form 7.3.27 to 7.4.15
  • Replaced the htaccess files for the other websites with the version that came with Magento 2.4.2

After upgrading the extra websites (not the default one) are redirected to de the default scope of the defult website.

One of my index.php files of the non-default websites:

require realpath(__DIR__) . '/app/bootstrap.php'; // path of root magento bootstrap.php 
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '*WebsiteCode*';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; 
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');

My .htaccess

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

I checked the websitecode and it is the correct one.

I checked the settings in the backend under Stores => Configuration => General => Web, the correct URL's are still there.

I use symlinks for the folder app, lib, pub and var.

2 Answers 2


Problem is solved, I added the following to .htaccess.

SetEnvIf Host ^(.*)domain.com MAGE_RUN_CODE=websitecode

SetEnvIf Host ^(.*)domain.com MAGE_RUN_TYPE=website


I created one new store. Means have total 2 stores.

  1. default
  2. trade
  • The default store have the main domain URL.
  • The trade store have subdomain URL.

So, for the trade store, I added 2 lines in the .htaccess file at the root.

SetEnvIf Host .*trade.maindomain.com.* MAGE_RUN_CODE=trade
SetEnvIf Host .*trade.maindomain.com.* MAGE_RUN_TYPE=store

It works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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