1

I got multiple Domains for different countries like:
www.domain.de
www.domain.be

Now i want to setup another Website within my Magento installation where www.domain.de is already setup and linked to a website and link the www.domain.be Domain to a new created Website to create a Shop for belgium.

Things I've already done:
• Create a new Website
• Create a Shop for that Website
• Create Storeviews for that Shop
• Configure the Base-URLS on the belgium Website

Belgium -> Belgium Shop -> dutch / french


When i try to access the www.null-bar.be Domain i do not get the right Website ( in fact i get the default screen from my hosting provider ) - The directory is set on the server-configuration.

I saw that i have to change things in the index.php to actually link the other domain to the right Website but none of the articles i've read was clear to understand...

Could anyone link a cleary understandable "tutorial" or article where i can make my stuff possible ?

5 Answers 5

3

Please follow http://vagento.com/setup-multi-store-multi-domain-magento-2/ link. I hope that'll help you for Setup Multi Store With Multi Domain in Magento 2.

3
  • Thank you for your answer, please take a look at my seperat answer since it better readable.
    – Marcel H.
    Commented Sep 12, 2017 at 10:24
  • what about 2.3 magento.stackexchange.com/q/256694/57334 @Emipro Technologies Pvt. Ltd.
    – zus
    Commented Jan 4, 2019 at 9:23
  • The URL returns a 404 code now. Please add the solution to your answer.
    – Ejaz
    Commented Jan 2, 2020 at 18:48
1

You seem to have done most of the work as I have not needed to change anything on index.php in the past and have just set the apache virtual hosts as per Dec docs articles at bottom of answer for it to work.

If using apache for web server I just created a new virtual host and added something like below for the new store:

<VirtualHost *:80>
ServerName          german.mysite.mg
DocumentRoot        /var/www/html/magento2/pub/
SetEnv MAGE_RUN_CODE "german"
SetEnv MAGE_RUN_TYPE "website"
</VirtualHost>

As you have set the store up within admin I believe as long as the code matches your code, root and domain matches your store should start to work. You don't seem to have a virtual host set up I believe as the web server is showing default page and would usually redirect to the first store otherwise so you need to do above however unsure of your environment.

Apache http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_apache.html

Nginx http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_nginx.html

4
  • Thanks for the answer, i took a look at the articles and found on the first lines You’re working on a development machine (laptop, virtual machine, and so on). Im not wirking on a development machine - its live and online
    – Marcel H.
    Commented Sep 12, 2017 at 10:12
  • Have you set up a virtual host for your new domain on the server?
    – harri
    Commented Sep 12, 2017 at 10:19
  • Not yet, i asked my hosting provider if thats possible to add. What if it is not ?
    – Marcel H.
    Commented Sep 12, 2017 at 12:32
  • It should be fine you will need to be able to at least add vhosts if you can get root access it should be fine to add Mage run code etc . If not the index.php can be be a good workaround but will need to still set that domain up on server so it points to your magento instance.
    – harri
    Commented Sep 12, 2017 at 14:44
0

@Emipro Technologies Pvt. Ltd.

Thanks for your answer, looks proising so far. The only thing i dont get is this one:

$domain2store = array(
'domain1.com'=>'default', // Replace your Website, Store or Storeview code with this.
'domain2.com'=>'de',      // Replace your Website, Store or Storeview code with this.
'domain3.com'=>'es',      // Replace your Website, Store or Storeview code with this.
'domain4.com'=>'fr',      // Replace your Website, Store or Storeview code with this.
);

Do I just have to fill in the storeview code and it gets the Shop & Website from that ? Or do I have to fill in the Website ID or Shop ID ?

Thank you.

1
0

UPDATE AND FINAL ANSWER
Since i wasnt able to create vhosts due "secruity concerns" from my hosting provider i was stuck with editing the index.php. I used the article linked from Emipro Technologies Pvt. Ltd. (which is also marked since it was the only article which was written in an understandable way and i got it to work like that.

0

Run another domain using same Magento2 Database

Step 1. Go to Store >> All Stores And Here Create New Website

Step 2. Then Create New Store for Newly added website

Step 3. Create New Store view for Newly added Store

Step 4. Go to Store >> Configuration >> General >> Web And Set Configuration Scope to Newly Created Website and Change Secure URL & Unsecure Url as New Website

Step 5. Open pub/.htaccess file and write these two lines

SetEnvIf Host mynewwebsite.com* MAGE_RUN_CODE=newwebsite_code

SetEnvIf Host mynewwebsite.com* MAGE_RUN_TYPE=website

All Done !

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.