3

I am trying to set up a second store based on a single magento installation. I have created the website, store, and store view as indicated in http://www.magentocommerce.com/knowledge-base/entry/tutorial-multi-site-multi-domain-setup

But when I visit my second store (using its own URL), I end up on the home page of my first store.

I have modified the .htaccess and httpd.conf, cleared the cache and restarted apache, as advised in the tutorial

Can you help me please ?

EDIT:

My changes to .htaccess:

SetEnvIf Host www\.broum-utilitaires\.com MAGE_RUN_CODE=broum_utilitaires
SetEnvIf Host www\.broum-utilitaires\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^broum-utilitaires\.com MAGE_RUN_CODE=broum_utilitaires
SetEnvIf Host ^broum-utilitaires\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\.broum-utilitaire\.fr MAGE_RUN_CODE=broum_vintage
SetEnvIf Host www\.broum-utilitaire\.fr MAGE_RUN_TYPE=website
SetEnvIf Host ^broum-utilitaire\.fr MAGE_RUN_CODE=broum_vintage
SetEnvIf Host ^broum-utilitaire\.fr MAGE_RUN_TYPE=website

My httpd.conf

<VirtualHost *:80>
    ServerAdmin contact@broum-utilitaires.com
    ServerName broum-utilitaires.com
    DocumentRoot /var/www/broum
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin contact@broum-utilitaire.fr
    ServerName broum-utilitaire.fr
    DocumentRoot /var/www/broum
</VirtualHost>
  • Have you made sure you store code match? - You also test by adding your exception codes directly to the index.php – brentwpeterson Sep 23 '13 at 13:45
  • I did double check and they match. How can I check that the SetEnvIf instructions in my .htaccess are taken into account ? Same question regarding my httpd.conf file ? – user3190 Sep 23 '13 at 15:13
  • Can you post your snippit from htaccess? – brentwpeterson Sep 23 '13 at 15:59
  • 2
    In index.php just var_dump($_SERVER); and see if your MAGE_RUN_CODE is set. – benmarks Sep 23 '13 at 16:22
  • Good call benmarks, I don't see any MAGE_RUN_CODE in the var dump. I have added my changes to .htaccess and httpd.conf. Any idea why they seem to be ignored ? – user3190 Sep 24 '13 at 9:05
2

I've found the cause of my problem. It came from a wrong configuration of the redirection from my domain name to the server (I shouldn't have used the domain's host redirection utility).

I've had to set up the domain name so that it's managed by my server's DNS. And very, very important, in the virtual host configuration, add

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

That's needed so that the .htaccess file is used, enabling the RewriteCond instructions needed for magento's multi-domain configuration.

Thanks to everyone who has contributed to resolving my problem !

0

You can try this in your index.php instead

switch($_SERVER['HTTP_HOST']) {
    case 'broum-utilitaires.com':
        $mageRunCode = 'broum_utilitaires';
        $mageRunType = 'website';
        break;
    case 'broum-utilitaire.fr':
        $mageRunCode = 'broum_vintage';
        $mageRunType = 'website';
        break;
}

You also test by replacing one of you codes with BASE to see if it switches between the two

I am adding an example of my .htaccess to accomplish this

RewriteCond %{HTTP_HOST} (.*)?domain1\.com [NC]
RewriteRule (.*) - [E=MAGE_RUN_CODE:domain1]
RewriteCond %{HTTP_HOST} (.*)?domain1\.com [NC]
RewriteRule (.*) - [E=MAGE_RUN_TYPE:website]


RewriteCond %{HTTP_HOST} (.*)?domain2\.com [NC]
RewriteRule (.*) - [E=MAGE_RUN_CODE:domain2]
RewriteCond %{HTTP_HOST} (.*)?domain2\.com [NC]
RewriteRule (.*) - [E=MAGE_RUN_TYPE:website]

Both of these methods work for me

  • It enters none of these cases... $_SERVER['HTTP_HOST'] is ns302288.ovh.net. How can I make this value equals to one of my domain ? By the way, I have created two re-directions: Both broum-utilitaires.com and broum-utilitaire.fr redirect towards ns302288.ovh.net/broum/index.php/ Is it the right thing to do ? – user3190 Sep 24 '13 at 15:52
  • I guess this explains a lot, if both domains are forwarded to this new domain it's gonna be hard, if not impossible, to fix this. You'll need to add store codes to the url to run the 2 shops – Sander Mangel Sep 24 '13 at 16:42
  • One of your sites should be the default? Can you try default in one of them – brentwpeterson Sep 24 '13 at 17:00
  • @SanderMangel, I don't understand your comment: According to the tutorial I've mentioned, there is no need to add store code to the url, they just need to be different. brentwpeterson, the thing is that $_SERVER['HTTP_HOST'] is always equal to my server adress, regardless of the url I have used to enter the site. – user3190 Sep 25 '13 at 7:57
  • that's exactly the issue, if your HTTP_HOST is always ns302288.ovh.net/broum/index.php/ you can't distinguis which shop to load. In that case you need a store code to do the mapping – Sander Mangel Sep 25 '13 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy