0

I would like to setup multi store. I have two domains:

  • example.com
  • french.example.com

I use this article: https://www.simicart.com/blog/magento-2-multiple-stores-domains/ and created:

Websites:
French (Code: french) 
Main Website (Code: base) 

Stores:
French (Code: french)
Main Website Store (Code: main_website_store) 

Store views:
French (Code: french) 
Default Store View (Code: default) 

Base URLs (Store View for Default config) is http://example.com. Base URLs (Store View for French) is http://french.example.com.

It works correct!

But, I would like to use Base URL "example.com" for both domains!

I mean, that

$this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB)

have to return "example.com" for store view French as well!

Now it returns "french.example.com" for French and "example.com" for Default.

Is it possible to setup this way?

0

I've tried to set up another way. I have entered for both domains Base URLs "http://example.com".

So, url for default sore view is:

http://example.com/default/

url for french store view is:

http://example.com/french/

But, I cannot setup, that http://example.com/french/ will redirected to http://french.example.com/

0

Make a Directory on root with name french and create file index.php place below code in this file.

<?php
/**
 * Application entry point
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

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>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}

$params = $_SERVER; 
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'french'; //Webite code as same in admin panel which we entered in step 2 
$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);
  • Thank you. I've tried your solution, but I still have this issue. – PHPer Oct 30 at 7:34
  • did you place your code in html directory. – Ali Hussain Oct 30 at 10:12
  • yes, I placed it to 'french/index.php' – PHPer Oct 30 at 10:41
  • strange i am using it with similar code. I have a multi website each with diff name. check your base urls in core_config_data table – Ali Hussain Oct 30 at 10:52

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.