cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2 Multistore with different domains not working

SOLVED

Magento 2.2 Multistore with different domains not working

I've two stores/websites setup with seperate base URLs. I followed the instructions from following page:

 

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

 

The first domain works fine but second domain keeps redirecting to first domain. Any idea what i am doing wrong here?

 

Many thanks for your help.

 

Shaz 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.2 Multistore with different domains not working

Hi Damian,

 

I managed to fix the problem by adding following code in .htaccess file:

 

SetEnvIf Host [domain1] MAGE_RUN_CODE=[website1 code]
SetEnvIf Host [domain1] MAGE_RUN_TYPE=website 
SetEnvIf Host [domain2] MAGE_RUN_CODE=[website2 code] 
SetEnvIf Host [domain2] MAGE_RUN_TYPE=website

I hope this will help others with same issue.

Thanks,

 

Shaz

View solution in original post

15 REPLIES 15

Re: Magento 2.2 Multistore with different domains not working

Hi @mdsadmin,

 

Did you configured your secodn vhost to handle the request of the second domain?

Which weserver are you using?

 

Re: Magento 2.2 Multistore with different domains not working

Hi Damian,

I am new to Magento so its possible that i've missed a very basic setting.

 

I've setup Magento using the CPanel and have added my second domain to "Addon Domains" section in CPanel which is pointing to root folder. Do i need to make any other changes?

 

Many thanks for your help.

 

Shaz

Re: Magento 2.2 Multistore with different domains not working

Hi @mdsadmin,

 

I guess you shouldn't do anything else.

I was trying today and I've got the same issue with different subdomains for multiples websites.

At this point I'm not completely sure if is a problem of configuration or is a bug (I've found some information on forum and github but I don't have a final answer yet)

Re: Magento 2.2 Multistore with different domains not working

Hi Damian,

 

I managed to fix the problem by adding following code in .htaccess file:

 

SetEnvIf Host [domain1] MAGE_RUN_CODE=[website1 code]
SetEnvIf Host [domain1] MAGE_RUN_TYPE=website 
SetEnvIf Host [domain2] MAGE_RUN_CODE=[website2 code] 
SetEnvIf Host [domain2] MAGE_RUN_TYPE=website

I hope this will help others with same issue.

Thanks,

 

Shaz

Re: Magento 2.2 Multistore with different domains not working

Do you only change the files in the second domain directory?

Did you change BOTH .htaccess and index.php?

 

Can you help me as mine is doing the same?  I have tried every combination of changes but cannot get mine to work.  Second domain keeps resolving to first instead of showing itself

 

Re: Magento 2.2 Multistore with different domains not working

If you want to use different domains for different store views/store under the same website, update .htaccess as follows:

SetEnvIf Host [domain1] MAGE_RUN_CODE=[storeview1 code]
SetEnvIf Host [domain1] MAGE_RUN_TYPE=store 
SetEnvIf Host [domain2] MAGE_RUN_CODE=[storeview2 code] 
SetEnvIf Host [domain2] MAGE_RUN_TYPE=store

Works on Magento 2.2.4 

Re: Magento 2.2 Multistore with different domains not working

I tried this but it's only working after visiting main site first.

 

1: Visit domain B (not default store for website)

2: Get redirected to domain A (default store for website)

3: Probably cookies get set.

4: Visit domain B again with proper store content rendered and correct domain.

 

Any ideas why this could be happening?

Re: Magento 2.2 Multistore with different domains not working

Also have the same issue, any chance you fixed the issue?

Re: Magento 2.2 Multistore with different domains not working

I have still same problem. Try so many things but nothing will work. We running 12 stores on 4 different domainnames. But some domains get redirected to website1.shop

website1.shop works

nl.website1.shop works

de.website1.shop works

website2.shop don't work, get redirected website1.shop

nl.website2.shop works

de.website2.shop works

etc.etc.

 

Somebody have a solution for this problem?