Magento – Magento 2 Multi Store with Sub-domain for B2B

b2bmagento2multistore

I need to create a new store for my e-commerce (not a new website, not a new store front) for B2B.

Now, my e-commerce is active on mobiroloshop.com (B2C) and I want the new store on b2b.mobiroloshop.com.

I've followed several tutorials but still have problems. If I create an alias (parked domain) on cPanel for B2B, when I type b2b.mobiroloshop.com,

I'm redirected to mobiroloshop.com. I tried both to change .htaccess file (following step-by-step this tutorial https://www.cloudways.com/blog/create-and-configure-multistore-magento-2/) and to use a switch statement on my index.php (to switch B2B or B2C based on $_SERVER content).

Can someone please help me with this struggling issue?

This is my Magento Stores configuration

My Magento store configuration.

Best Answer

I had the same problem. What's missing is the environment variable.

Add to your .htaccess file

SetEnvIf Host b2b\.mobiroloshop\.com MAGE_RUN_CODE=b2b
SetEnvIf Host b2b\.mobiroloshop\.com MAGE_RUN_TYPE=store

If your server is Nginx, check: http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_nginx.html

Regards

Related Topic