1

I have 2 sites running on Magento 1.8.1 and each site has a different domain. I would like to have 3 store views for each site.

Each site will have 3 languages.

Each language will use the same TLD. Languages will be denoted by using /en/ in the url.

Here's what I'm trying to get it to look like:

http:website-a.com/en/product.html
http:website-a.com/es/product.html
http:website-a.com/fr/product.html

http:website-b.com/en/product.html
http:website-b.com/es/product.html
http:website-b.com/fr/product.html

I can easily achieve this on only one site by simply using the "Add Store Code to Urls" option in Magento Admin. However, Magento will not allow me to use the same store code twice. Furthermore, If I decide to run a third website that only has one language, I wouldn't want to insert any store code.

e.g.(http:website-c.com/product.html)

but unfortunately

the "Add Store Code to Urls" option is global and cannot be changed on a per-site or per-store basis.

So, how would I go about setting this up to work right? Should I use unique values for each store view and then do rewrites? How would that work? I don't really understand how to write rewrite rules.

Or could I do something in index.php?

Any help is appreciated :)

1
  • The simplest solution might be to use a combination of RewriteCond's in your .htaccess file (or preferably VirtualHost), to set the MAGE_RUN_CODE env variable base on the HTTP_HOST and REQUEST_URI. Mar 19, 2015 at 17:59

1 Answer 1

1

This is probably not the best solution but it should work. It involves sub-folders and symbolic links.

First you need to create 2 separate root folders for both domains. One of them will actually contain the magento install. Both folders will contain subfolders for each language. Inside each subfolder you should create one index.php file and assign the store code it should load. Also, each subfolder should contain it's own var folder and symbolic links to the rest of magento's folders (app, lib, media, etc).

You also need to create all storeviews, and you can add whatever code you want because you will only use it in the index.php file of each subfolder. Then you should disable the "Add Store Code to Urls" setting in magento, and set the base url for each store view accordingly.

Your structure should look like this

/var/www/websiteA/
 - app
 - media
 - lib
 - var
 - index.php
/var/www/websiteA/en/
 - app   -> ../app
 - media -> ../media
 - lib   -> ../lib
 - var
 - index.php
/var/www/websiteA/es/
 - app   -> ../app
 - media -> ../media
 - lib   -> ../lib
 - var
 - index.php
/var/www/websiteA/fr/
 - app   -> ../app
 - media -> ../media
 - lib   -> ../lib
 - var
 - index.php

/var/www/websiteB/
 - app   -> ../websiteA/app
 - media -> ../websiteA/media
 - lib   -> ../websiteA/lib
 - var
 - index.php
/var/www/websiteB/en/
 - app   -> ../../websiteA/app
 - media -> ../../websiteA/media
 - lib   -> ../../websiteA/lib
 - var
 - index.php
/var/www/websiteB/es/
 - app   -> ../../websiteA/app
 - media -> ../../websiteA/media
 - lib   -> ../../websiteA/lib
 - var
 - index.php
/var/www/websiteB/fr/
 - app   -> ../../websiteA/app
 - media -> ../../websiteA/media
 - lib   -> ../../websiteA/lib
 - var
 - index.php

Using this approach you can also load different store views for each root domain. For example websitea.com can load the store view websitea_default, when websitea.com/en can load the storeview websitea_en

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.