Multistore not working after upgrading from 2.3.5-p1 to 2.4.2
-
15-04-2021 - |
Question
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:
<?php
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');
$bootstrap->run($app);
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.
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange