Hi everybody,
I recently inherited a magento westore that is configured with two store. In production everything is working fine with two different domain. I tried to make it work in local but I am having some trouble to open the second store that actually loads the main store.
I cannot use the hosts file to create some mock domain and redirect them to localhost because I have to find a solution that will work also on my test environment, where the client will to access true the server ip and I cannot ask them to modify the hosts file, unfortunately I even don't have a domain to use for the test env at the moment.
Because of this reason I have two virtualhosts on two different ports. Configured in this way:
Listen 80
<VIRTUALHOST>
ServerAdmin admin@localhost
ServerName app
#ServerAlias www.app
SetEnv FIRST_STORE true
DocumentRoot /var/www/app
<DIRECTORY>
Options Indexes FollowSymLinks
AllowOverride All
AddDefaultCharset utf-8
Require all granted
</DIRECTORY>
</VIRTUALHOST>
Listen 81
<VIRTUALHOST>
ServerAdmin admin@localhost
ServerName app
#ServerAlias www.app
SetEnv FIRST_STORE false
DocumentRoot /var/www/app
<DIRECTORY>
Options Indexes FollowSymLinks
AllowOverride All
AddDefaultCharset utf-8
Require all granted
</DIRECTORY>
</VIRTUALHOST>
and I added in the index.php this lines:
$isFirst = apache_getenv ( "FIRST_STORE");
$params = $_SERVER;
if($isFirst == 'true'){
$params[\Magento\Store\Model\StoreManager:
ARAM_RUN_CODE] = 'first';
$params[\Magento\Store\Model\StoreManager:
ARAM_RUN_TYPE] = 'website';
}else{
$params[\Magento\Store\Model\StoreManager:
ARAM_RUN_CODE] = 'second';
$params[\Magento\Store\Model\StoreManager:
ARAM_RUN_TYPE] = 'store';
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
Despite of this configuration the second store is not loading. Where am I wrong and how can i solve this issue?
Thanks to everybody who will help me.