Magento – Mutiple website with multiple sub domain in Magento 2

base-urlmagento-2.1.3multi-website

I'm trying to implement multiple website in Magento 2.1.3 For that, I have created an extra website store and store view

My site URL is like www.example.com

My subdomain is www.kw.example.com(where kw is the code of new website).

I have create sub domain in my domain and point this in to a new folder in Magento root folder which contain the index file of new website.
And i have changed the website URL and secure BASE URL as www.kw.example.com
but when i try to access to this URL its redirecting in to www.example.com

Best Answer

Follow this and comment for any issue:

  1. Verify your desired domain name points to the server.
  2. Create a secondary domain for your new store.
  3. Using either FTP or SSH, copy the .htaccess and index.php files from your Magento installation to the document root of your new domain.
  4. Open the index.php file that you just copied and edit the last lines of the file as follows:

Attention: Change newstore to the code that you wrote down when you created the new website above.

Replace:

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);

With:

require __DIR__ . '/app/bootstrap.php'; $params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'newstore'; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app);

  1. Using SSH, create the following symbolic links in the document root of your new domain, and replace the path below with the full path to the document root of your Magento Installation:

ln -s /home/example/example.com/html/app/ app

ln -s /home/example/example.com/html/lib/ lib

ln -s /home/example/example.com/html/pub/ pub

ln -s /home/example/example.com/html/var/ var

Update in Your case:

Replace ln -s /home/example/example.com/html/app/ app with ln -s /var/www/html/m2/example.com/app/ app

Related Topic