Assigning each Store View a Unique Domain

Hi Craig, hi guys,

After a long battle I was able to install my language packs. A BIG THANK YOU for you Craig for your time and checking on this for me!!!
By the way it is very simple.
My currencies are also set up.

Now I would like to configure Magento so each store view loads with a unique domain.
I.e. for the UK mysite.co.uk, for Germany mysite.de and for France mysite.fr

The link below explain how to add new website, store, store view in the Magento admin panel.
It is pretty easy.
https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_websites.html

I’m trying to digest this doc:
https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_apache.html#ms-apache-vhosts

I’m guessing I need to modify the virtual host configuration file.
I’m guessing it is the file “000-default.conf” in /etc/apache2/sites-available directory. Please correct me if I’m wrong.

Using surper user account a run the following command:

sudo nano /etc/apache2/sites-available/000-default.conf

My 000-default.conf looks as follow: (I deleted all commented lines to reduce the number of text )

def

I have two store views other than the default: mysite.fr and mysite.de.
My both website and store codes are the same

website code - “default”,
store code - “main_website_store”

Only store views codes differ. For the French language “fr” for German “de” and for my default English language - “default”

And here I’m a bit confused.
As I understand from the article https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_apache.html#ms-apache-vhosts I need to create 2 additional virtual hosts for 2 store views and the existing one hmmm…

Should I add the bellow?

Thank you for any help, suggestion, link video.

Regards,
Pawel

I haven’t done a setup like this since probably 2013/4… Perhaps this post can shed some light: Configure multiple domain names on apache2

Hi,

Im still diging in it and trying to find our some more info.

Found this
https://devdocs.magento.com/guides/v2.3/cloud/project/project-multi-sites.html
but it will take me ages to digest it and no neccessairly how to figure out how to bite is and implement correctly.

If anyone knows how to do it please contribite.
Thank you.

Pawel

The link you sent me gives a bit of light on the toppic but my innitial setting didn’t work.

I have a SSL installed on my default domain which make it a bit complicated.
I need to siplify it at frist. I’ll remove the cetificate then I’ll start playing with the multi-domain set up and finally I’ll try to install the ssl. And again it will be tricky. How to install a few certificats for each domains.

If anyone know how to configure please let me know.

Pawel

Hey Pawel! Have you found a solution? I am working on the same thing and also seeing that it is tricky with SSL. Do you know if default conf files need to be disabled in order to make the new conf file per domain work?

Thank you to anyone who could point me in the right direction!

Hi,
I gave up with this for now.

Please keep me posted if you work out how to do it.

Pawel

So I guess I sort of gave up, too, and set things up with subfolders, which seems to work fine. The problem I have now is I cannot properly redirect from, say, mydomain.de to mydomain.eu/de (both domains point to my DO droplet, so they now show the default storeview).

I tried doing the VirtualHost setup modifying the /etc/apache2/sites-available/magento-ssl.conf to have mydomain.de point to a website, which seemed to have some effect, but only on Opera for some reason)

So still a long way away from understanding how to achieve this…

Hi, please update what you found out. If you can of course.
Thank you.

Right now i have these settings in my /etc/apache2/sites-available/magento-ssl.conf since none of the other files seem to have any effect on apache2. Don’t know if it is ok to edit magento-ssl.conf but it works to some extent) As in, when I type http://www.mysite.de in, it redirects to the correct storeview mysite.eu/de

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    ServerName mysite.de
    ServerAlias www.mysite.de
    SetEnv MAGE_RUN_TYPE "store"
    SetEnv MAGE_RUN_CODE "de_DE"
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    ServerName mysite.co.uk
    ServerAlias www.mysite.co.uk
    SetEnv MAGE_RUN_TYPE "website"
    SetEnv MAGE_RUN_CODE "b2c_gbp"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    ServerName mysite.eu
    ServerAlias www.mysite.eu
    SetEnv MAGE_RUN_TYPE "website"
    SetEnv MAGE_RUN_CODE "base"
</VirtualHost>

I have https://mysite.eu/de/ and https://mysite.eu/gb/ set up in the magento admin accordingly, so when http://www.mysite.de (note that it is not secure) is typed in, it redirects to mysite.eu/de/. Not sure I love it that way, but that’s the only way i have gotten it to work) Doesn’t work with https, hence probably why i was seeing the result on opera, it might be doing some automatic http to https redirection. I have now found someone on upwork to help me out, so if they come up with a solution, i will post it here.

upd: people on upwork quoted 6 hours to get this sorted so I am back to the drawing board)