I want to create multistore website in magento2 for this my current system configuration is as follows-
- Web server: Nginx
- Magento Version: magento2.1.0
- Cento OS Version: 7
for this I have followed below steps:
Created Website/Store/View in magento2 admin.
Added below code in pub/index.php
$params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [ DirectoryList::PUB => [DirectoryList::URL_PATH => ''], DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'], DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'], DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload'], ]; switch($_SERVER['HTTP_HOST']) { case 'electronics-dev.local': case 'www.electronics-dev.local': $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'electronics'; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; break; case 'magento2-dev.local': case 'www.magento2-dev.local': $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); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app);