I use magento 2.0.2 on Siteground. I did configure a multiple store views with 2 domains. Regarding the Url Options I added Store Code to Urls. I have 2 domains with 2 languages for each.
Regarding the main domain (www.example1.com) it's working perfectly on both languages.
Regarding the second domain it is working if I have www.example2.com/english or www.example2.com/french. If I try to write www.example2.com it doesn't work and redirect it to www.example1.com.
Here is what I did :
With Siteground I created an addon domain.
With Siteground I used let's encrypt for www.example2.com
on my hosting, in the public_html with my magento 2 installation from www.example1.com, I have a new folder created :example2_com. I copied my .htaccess and my index.php from my main website to the example2_com folder.
In the index.php I modified it with :
$params = $_SERVER;
use Magento\Store\Model\StoreManager;
if ($params['HTTP_HOST'] == 'www.example2.com') {
$params[StoreManager:ARAM_RUN_CODE] = 'example2CODE';
$params[StoreManager:ARAM_RUN_TYPE] = 'website';
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
Then I used the SSH connexion in my example2_com for :
ln -s ../app/ app
ln -s ../lib/ lib
ln -s ../pub/ pub
ln -s ../var/ var
I didn't change anything in the .htaccess
www.example2.com/english is working, www.example2.com/french is working too but not www.example2.com as it redirect it to www.example1.com.
Did I miss something ? Is someone has any idea how to correct it ?
Thanks for your help.
Solved! Go to Solution.
Find a solution. I had to change in my index.php :
$params = $_SERVER; use Magento\Store\Model\StoreManager; if ($params['HTTP_HOST'] == 'example2') { $params[StoreManager::PARAM_RUN_CODE] = 'example2code'; $params[StoreManager::PARAM_RUN_TYPE] = 'website'; } $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app);
by this :
$params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'example2code'; $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);
I spend about a week trying to configure 2 domains on 2 storeviewes. I was not able to get it working, even with the online help.
What I did is create 2 stores, then things kid worked. Except the category names were totaly screewed up.
Sometimes whey were in language A, sometimes in language B...
So I got all possoble combinations
domainA/languageAcategory/product.html
domainB/languageAcategory/product.html
domainA/languageBcategory/product.html
domainB/languageBcategory/product.html
But i fixed this manual in the DB.
Find a solution. I had to change in my index.php :
$params = $_SERVER; use Magento\Store\Model\StoreManager; if ($params['HTTP_HOST'] == 'example2') { $params[StoreManager::PARAM_RUN_CODE] = 'example2code'; $params[StoreManager::PARAM_RUN_TYPE] = 'website'; } $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app);
by this :
$params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'example2code'; $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);