Is it possible to run two Magento 2 websites on a single domain? I want to share the user between this websites. but want to redirect them to different stores (same URL - without store code) after they login based on their user group. That two store will be having same catalogs and identical store view.

I'm just doing this for separate user experience, like to make available different payment method, shipping and catalog visibility based on the user group, that is not available in magento base setup.

  • I have one question, How can I use a single user account for two different Magento. both have different db, how can I manage it? Is it possible? also if I added same customer details in both databases then is it possible to login automatically for both site? Jan 12 '19 at 10:29

here is the answer https://gist.github.com/thagxt/0f605f0a8a95c79302db0d2f04383788

we can create separate store in sub directory, so they run on same domain (no sub domain) and there is no need to make change in httpd or .htaccess


There's another way to do that, in Stores > Settings > Configuratio >web:

  1. Set your new site's url to that of the base_url(ex: www.website.com/)
  2. Set the option of 'add store Code in URLs' on.
  • Magento v2.4.*
  • LAMPP stack
  • OS - Ubuntu

Magento 2 single domain multi website

  • Create multiwebsite in magento2 and set base url /fr , /mx

  • Create sub directory inside pub dir

  • Copy pub/.htaccess and pub/index.php into sub dir

  • Update pub/fr/index.php

     use Magento\Framework\App\Bootstrap;
     try {
         require __DIR__ . '/../../app/bootstrap.php';
     } catch (\Exception $e) {
         echo <<<HTML
              <div style="font:12px/1.35em arial, helvetica, sans-serif;">
              <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
                  <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
         Autoload error</h3>
     $params = $_SERVER;
     $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'DFR'; //Webite code as same in admin panel
     $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
     $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
     $bootstrap = Bootstrap::create(BP, $params);
     /** @var \Magento\Framework\App\Http $app */
     $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
  • Create symlinks for static, media and error files

     cd pub/fr 
     ln -s ../media media
     ln -s ../static static
     ln -s ../opt opt
     ln -s ../errors errors

Clear cache and redeploy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.