3
votes

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

1
Do you use .htaccess for setting the store to run or index.php? Please show how you configured them. When using .htaccess check if mod_setenvif is enabled enabled. Not all hosters support this method.Simon H
This sounds like your store code is not correctly set. How do you actually set it? .htaccess? index.php?Grimace of Despair
it's resolved now. it was a problem with the setEnv of apache configAlive Developer

1 Answers

1
votes

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

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/http
    ServerName domain0.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/http
    ServerName domain1.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    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