In Magento 2 I try to add specific base url for store view.

This is my configuration :

My website 1 contains two store view :

  • Store view 1 : my_store_view_1
  • Store view 2 : my_store_view_2

Base urls secure unsecure are configured like this :

  • my_store_view_1 : mydomain.com/fr/
  • my_store_view_2 : mydomain.com/nl/

I have created two subfolders in magento root :

  • <magento_root>/fr/
  • <magento_root>/nl/

Each folder contains copy of root .htacces and index.php with :


require realpath(__DIR__) . '/../app/bootstrap.php';
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'my_store_view_1';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);

$app = $bootstrap->createApplication('Magento\Framework\App\Http');

When I visit "mydomain.com" I 'm successfully redirected to "mydomain.com/fr/" but only homepage is working, other pages are 404 not found.

When I visit "mydomain.com/nl/" I'm redirected automatically to "mydomain.com/fr/"

Do you know what is missing in my configuration ? Thanks

  • Check devhooks.in/blog/setup-multi-store-multi-domain-magento-2 hope it'll help you.
    – MK Patel
    Commented Apr 26, 2022 at 13:09
  • @Mayank-Dolphin thanks but it doesn't work. $_SERVER['HTTP_HOST'] return only domain and not complete url with "/fr/" or "/nl/"
    – Fbr
    Commented Apr 26, 2022 at 13:52
  • Are you using the same domain for both store views?
    – MK Patel
    Commented Apr 27, 2022 at 5:09
  • @Mayank-Dolphin Yes same domain fro both store views : mydomain.com/fr/ and mydomain.com/nl/
    – Fbr
    Commented Apr 28, 2022 at 8:49

1 Answer 1


As per your Comment You just need to enable only Add Store Code to Urls = Yes.

Under Admin > Store > Configuration > Web > URL Option > Add Store Code to Urls = Yes.

  • No because my store view codes are not just only "fr" and "nl" it's "my_store_view_1" and "my_store_view_1" and I can't change these store code for other reasons. I want to change base_url and not enable Add Store Code to Urls
    – Fbr
    Commented Apr 28, 2022 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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