Alive Developer
Alive Developer

Reputation: 1022

Magento and multiple domains

I'm trying to build a store with multiple domains, based on the language: for example mysite.com (english), mysite.it (italian), mysite.ru (russian).

I'm following this and this, but i think it could be a non-magento problem.

My apache setup is the following:

<VirtualHost *:80>
ServerName mysite.rb.com
ServerAlias mysite.it
ServerAlias mysite.ru
...

the problem is that if I print to the log the http host, it's always:

[HTTP_HOST] => mysite.com

also if i type mysite.it or mysite.ru Am I doing anything wrong with apache? Should i declare another virtual host instead of an alias?

If I can't recognize properly the requested host, I also can't show the correct store.

PS: unsecure and secure base urls have been set to the correct domain name, each one for the proper language

EDIT: now I am sure that it's not an apache problem. I deleted the directory of my project, and apache did not send a 302 redirect. So Magento is handling this redirect by itself

Upvotes: 3

Views: 3430

Answers (1)

Francis Kim
Francis Kim

Reputation: 4285

The apache virtual host setup is wrong. You need separate virtualhost entries for each domain as the following:

<VirtualHost *:80>
    ServerAdmin webmaster@domain1.com
    DocumentRoot /var/www/http
    ServerName domain0.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@domain2.com
    DocumentRoot /var/www/http
    ServerName domain1.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@domain3.com
    DocumentRoot /var/www/http
    ServerName domai2.com
</VirtualHost>

And also the .htaccess file in your Magento root directory:

SetEnvIf Host www\.domain1\.com MAGE_RUN_CODE=domain1_com
SetEnvIf Host www\.domain1\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain1\.com MAGE_RUN_CODE=domain1_com
SetEnvIf Host ^domain1\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\.domain2\.com MAGE_RUN_CODE=domain2_com
SetEnvIf Host www\.domain2\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain2\.com MAGE_RUN_CODE=domain2_com
SetEnvIf Host ^domain2\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\.domain3\.com MAGE_RUN_CODE=domain3_com
SetEnvIf Host www\.domain3\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain3\.com MAGE_RUN_CODE=domain3_com
SetEnvIf Host ^domain3\.com MAGE_RUN_TYPE=website

Refer to the following link for more information:

http://www.magentocommerce.com/knowledge-base/entry/tutorial-multi-site-multi-domain-setup

Upvotes: 1

Related Questions