SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH

How to create multiple websites in Magento 2?

Today, I will guide you how to create multiple websites in Magento 2.

First step: Create multiple websites in the backend.

Admin Panel > STORES > Settings > All Stores > Create Website > enter information of your new website > Save Web Site

Admin Panel > STORES > Settings > All Stores > Create Store > Web Site > select website that you have create on above > enter information of your new store > Save Store

Admin Panel > STORES > Settings > All Stores > Create Store View > Store > select store that you have create on above > enter information of your new store view > Save Store View

Second step: Confinfigure the domain for each website.

Admin Panel > STORES > Settings > Configuration > Scope: > select the website that you have create > GENERAL > Web > Base URLs > Base URL > enter domain for this website > Base URLs (Secure) > Secure Base URL > enter domain for this website with secure > Save Config

 

Third step: Change file index.php to add correct the redirect.

Change this code(I will use Magepow – The Best Magento 2 Extensions and Services (http://magepow.com) for new domain, you must change it to your domain):

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

 

To:

switch($_SERVER[‘HTTP_HOST’]) {

    case ‘Magepow – The Best Magento 2 Extensions and Services (http://magepow.com)’:

        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = ‘new_website_code’;

        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = ‘website’;

        break;

    default:

        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = ‘base’;

        $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = ‘website’;

        break;

}

 

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);

 

Note: You may need to point your new domain to your Magento before do those.