How to set multiple websites with multiple store views in Magento

How to set multiple websites with multiple store views in Magento

If you work with Magento, sooner or later you will end up needing multiple websites that have
multiple languages.
Most of you know this, but I hope someone will still find this post useful.

There are few ways of doing same thing, but in my experience way I’m going to present now causes
less problems even though it is less automatic than some other ways.

Let’s say we want 2 websites and 2 languages for each site.

Here’s procedure:

In admin panel, go to System->Configuration and click on “Manage Stores”
Click on “Main Website” to change it’s name to “Website 1” or however you want to call it. (I’ll call mine “Website 1” for the purposes of this article).
In “code” field there, write something like “website_1”.

Do same for “Main Website Store”. Call it “Website store 1”.

And guess what… do same for “Default Store View” that you can find on same interface.
How to call it?
Hm… I’ll call mine “English Store View”
I’ll write “english_store_view_website_1” in “code” field there.

Ok, let’s go make second one…
Add website named “Website 2” with code “website_2”.
Add store called “Website store 2” and assign it to Website 2 that you can chose from dropdown.
Add new store view called “English Store View” with code “english_store_view_website_2” and
assign it to “Website 2” that you can find in dropdown.

By now you should have 2 websites with 1 language each.

Add two more store views.
Call first “German Store View” with code “german_store_view_website_1”.
Call second “German Store View” with code “german_store_view_website_2”.
Assign them to corresponding websites.

Let’s see what we have at this moment:

1) a) Website 1 (code: website_1) – Website Store 1 English Store View (code: english_store_view_website_1)
b) Website 1 (code: website_1) – Website Store 1German Store View (code: german_store_view_website_1)

2) a) Website 2 (code: website_2) – Website Store 2 English Store View (code: english_store_view_website_2)
b) Website 2 (code: website_2) – Website Store 2German Store View (code: german_store_view_website_2)

Of course, I didn’t mentioned that you will need to chose root category for your stores, do what ever you like there.

Ok, let’s say we want url to be handled this way:
1) http://www.yourdomain.com/website_1
2) http://www.yourdomain.com/website_2

In your Magento installation directory, make 2 directories called “website_1” and “website_2”
Copy .htacces and index.php from your root directory in each of those new directories.

In .htaccess search for “RewriteBase /” line and replace it with “RewriteBase /website_1/” in first directory, and
search for “RewriteBase /” line and replace it with “RewriteBase /website_2/” in second directory.

In both directories open index.php and change “$compilerConfig = ‘includes/config.php’;” to
$compilerConfig = ‘../includes/config.php’;

Change $mageFilename = ‘app/Mage.php’; to $mageFilename = ‘../app/Mage.php’;

In same file make sure to edit Mage::run() function for each site:

Mage::run(‘website_1’, ‘website’);
Mage::run(‘website_2’, ‘website’);

Go to System->Configuration and select Current Configuration Scope: Website 1

Set absolute paths to your skin, js andΒ  media directories and set Base URL = http://www.yourdomain.com/website_1Β  (do that for website_2 too)

Now use this dirty way to switch between websites πŸ™‚
https://inchoo.net/ecommerce/magento-snippet-for-switching-between-websites/

Since there is much to say about this subject, feel free to ask questions and I’ll try to answer them asap.

Related Inchoo Services

You made it all the way down here so you must have enjoyed this post! You may also like:

How To Connect Google Analytics 4 To Magento 2 Bojan Mareljic
Bojan Mareljic, | 36

How To Connect Google Analytics 4 To Magento 2

3 best open-source eCommerce platforms in 2021 Zrinka Antolovic
Zrinka Antolovic, | 8

3 best open-source eCommerce platforms in 2021

Get rewritten product url in a different store Petar Sambolek
Petar Sambolek, | 9

Get rewritten product url in a different store

127 comments

  1. Hello , I have a main website and have 5 store view but i want these 5 store view have different website name and different store name. and assign different domain name to them. Is it possible?

  2. Hi,

    I have setup multiple websites (website1 and website2) by following this tutorial. The home page works fine for both websites however, it gives 404 page not found error while navigating to category and products in website2. Can anyone please point me in the right direction to fix this problem?

    Regards

    1. You probably have error in your website_2 .htaccess file. I had the same problem and had marked wesbsite_2 instead of website_2 in the .htaccess config

  3. Hello every one
    If you getting this error ../app/Mage.php was not found
    Please Try this /../app/Mage.php
    This is work for me.

  4. I got the project that client need website with multi language and multi currency. i have know idea how to do it because i a little bit confuse between web store and store view

  5. if we want the same url like : http://www.yourdomain.com , is still we need to create β€œwebsite_1” and β€œwebsite_2” directories ? we created only multiple store views. is there any changes we need to do in .htaccess file ?

  6. Hi!
    I have set up a second website with one store and two store views (for two languages).
    The second website requires lower prices than the first. The problem I am facing is, that I am only
    able to set a price per store view, that means in order to assign a different price for website two I will
    have to do it twice as I can’t select the website scope in order to have the price change affect both
    store views.
    I have change the config setting for catalog price scope from global to website.
    I have tried to run the second website on a different root catalog or on the same as the first one to
    no avail.
    Is this supposed to work like that?

    Regards

  7. Is there any way to setup extensions for multi store sites ? Like enable extension for 1 site and disable for another.

    1. If you want to disable an extension simply go under system > configuration > advanced. Select your store and disable the extension you don’t want.

  8. Hi!
    I Have my shop in 2 languages, but i cannot seem to change a few of the details on the site in the second language which is Romanian. For example in the menus I don’t know how or where to change the “wiev all” text to the romanian version “Vezi tot”

  9. Hi,

    I’m already setting my site follow by your tutorial, but i’m get

    ../app/Mage.php was not found

    on my second website. May i know what did i do wrong?
    Hope to hear from you.

    Regards.

  10. Uhm… my question is: I have 1 website, with N different stores (a main website and N – 1 stores which display a subset of categories/products of the main website), each store has 4 languages.
    So, let’s say I have STORE_MAIN and STORE_SUB_1, and each store has VIEW_ENG, VIEW_FRA, VIEW_DEU. Now, on STORE_MAIN.VIEW_FRA I can see my products and categories translated into French, but when I switch to STORE_SUB_1.VIEW_FRA, products are still in plain English. I assume it’s the way Magento handles Store/View, but it makes product managament damn hard if for any product I have to change the French translation N times on any VIEW_FRA of each store. I’m pretty sure I’m missing something obvious and I’d be glad if someone out there can help me!

  11. I’m trying to add a different language for my store for a week now… But I still have a problem and I don’t know what to do anymore.
    I have one website, one store and I want two languages (the default is Dutch). I want to add an English version with the same products. When I go to the “Manage” store part, the English store view is visible and enabled. But when I go to Admin > Configuration and I want to go to the English store view, there’s nothing there in the dropdown menu of the Current Configuration Scope, only the default config and the Default Store View (the dutch one). Also when I’m trying to change the name of the Dutch one, it looks like Magento only updates it in “Manage Stores” and not anywhere else. I’m desperate right now.

    Reindex or cache doesn’t work… Already tried that. The default config option in Web > URL options > Auto-redirect to Base URL is set to “No”. Can anyone help me??!!!

  12. I am also trying to do what Felix is. Is there any way to link store views with the same store code perhaps and update the descriptions across all storeviews?

    My store setup:

    Website
    Store
    Store Views

    UK
    UK Company
    – English
    – French
    – German
    – Spanish

    US
    US Company
    – English
    – French
    – German
    – Spanish

    EU
    EU Company
    – English
    – French
    – German
    – Spanish

    Hopefully someone can point me in the right direction.

  13. Hi All.
    I have two websites.
    1) International
    2) Us

    Each website had two store view (langauge)
    1.a International_franch
    1.b International_english

    2.a Us_franch
    2.b Us_english

    So, I have one question. How can do, that product attributes were the same values for International_franch and Us_franch websites. I want change product name or product description for two franch store views one time. Can I do that?

  14. Solved!!!!!!!!!!!

    copy the .htaccess and index.php to your new directory
    edit the index.php and change only the last line

    Mage::run(‘newstore’, ‘website’);

    Finally, using SSH, create the following symbolic links in the document root of your new domain:
    NOTE: Replace the path below with the full path to the document root of your Magento Installation.

    ln -s /home/example/example.com/html/app/ app
    ln -s /home/example/example.com/html/includes/ includes
    ln -s /home/example/example.com/html/js/ js
    ln -s /home/example/example.com/html/lib/ lib
    ln -s /home/example/example.com/html/media/ media
    ln -s /home/example/example.com/html/skin/ skin
    ln -s /home/example/example.com/html/var/ var

    Best Regards

  15. Dear,

    I have create 3 websites, 1 in the home directory and 2 in a sub directory (lb and intl) everything work fine in the 3 websites except the add to cart button in the 2 sub directory websites. How can we solve it. I use the magento 1.8.1

    Thanks

  16. I am created two stores using this tutorial,but i need different themes for stores.what i do for that?

  17. Hi,

    I need a solution similar like that but the problem is I have a lots of categories in every store, now if I make 2 store views for every store then it’ll be a huge category setup. Now according to above example, I have to manage all categories for every store view. How can I overcome with this situation. Please help!!!

  18. Hi Tomas,
    Great tutorial! english_store_view_website_1 has English as default that I can re-use in english_store_view_website_2.
    But how can I re-use the data of german_store_view_website_1 without having to copy al the data to german_store_view_website_2?

  19. sir i have tried this “http://www.geekieblog.com/2011/10/adding-a-new-language-to-magento/

    ” ,, it shows option in dropdown but does not translate the store into that particular language,, can any body resolve it where i am making mistak,, thanks alot…

  20. i am getting Internal Server Error when i go to any links both websites home page loading successfully any help please

  21. Thank you for this – very informative. When I select Add to Cart on a product, it reverts back to the other country (ie. I have a site for Canada, and one for the US. When I select the US site from the drop down, and click Add to Cart, it defaults to the Canada Shopping Cart.)

    Must be a configuration missed somewhere – any ideas?

    I’m running Magento ver. 1.7.0.2 (and yes, my base URL is http://www.thingsthegame.com/orders/ for both and the base link is http://www.thingsthegame.com/orders/canada for Canada Site and http://www.thingsthegame.com/orders/us for US Site

    Any help or suggestions would be great!!! Thanks in advance πŸ˜€

  22. @Neha, i assume you are using 1.7.0.2. After copying the index.php from root to your website folder wont work. You need to tweak the lines on 47 & 52

    Change it from

    $compilerConfig = MAGENTO_ROOT . '/includes/config.php';

    to

    $compilerConfig =  '../includes/config.php';

    and

    $mageFilename = MAGENTO_ROOT . '/app/Mage.php';

    to

    $mageFilename = '../app/Mage.php';

    This should fetch the file now.

    However, i still have a problem that i can see my 2nd website with the right category, but clicking on the category, it takes the link of default website like http://www.test.com/paintings.html instead of http://www.test.com/website_2/paintings.html

    It is missing the website_2 in the link.

    Any takers to help on this?

  23. I have follow this guide but not work, i have this problem :
    Parse error: syntax error, unexpected ‘{‘ in /data/web/e29834/html/website_2/index.php on line 47

  24. I am following the same steps…I have created two different stores…But the first problem i am getting is I cannot access to two different stores at the same time..means..I have to set one store as default…the other will not work…..

  25. hi all;
    i have a problem in magento site. i have website with
    five store view i want assign individual product to individual store view .
    could any help me plz..

  26. I use 4 stores build on 1 system. Not all products are shown on each store. I have problem with breadcrumbs, they are showing wrong, and linking to another store? any solution?

  27. Case: 1 magento installation, 5 stores each with 6 store views. By default magento creates seperate increments and prefixes for each and every store view. I want to realize increments and prefixes per store. All store views per store have to share their increments and pre fixes. – I’ve been looking for ages, hope someone here can help me in the right direction.

    Thanks in advance

  28. Hi,
    I have followed all the step to create the store and it does.
    When I enter the store path ie.
    http://magentodemo.localhost/website_1/
    it show the home page without CSS. ie page with
    just Store information without any images and template.
    Could you plz tell me what goes wrong while creating
    store.
    Thanks in Advance.

  29. I’ve successfully managed to get multistore working (second domain name is loading second magento store) but no css/design is loading – what is the best (correct) process to get the second store to load it’s theme (I thought just inserting the name of the theme in the admin -> system -> configuration -> design for the second store would do it but it doesn’t seem to be grabbing the design at all. Thanks

  30. Hi Thomas, thanks for this blog. Looks simple πŸ™‚ But not working for me. Hope you can help me.

    I have this setup

    Main Website – Main store – Language 1 (code: nl)
    Main Website – Main store – Language 2 (code: fr)

    I want the first to just be the root. So no changes there.
    For the fr one I have added a folder, changed index.php, changed the .htaccess and the urls.

    I always get a 404 page with the toplinks but nothing else. I think he cannot load the cms pages or something. Do you know what is wrong?

  31. This is almost exactly what I had to do, thanks! (two websites, each with one store/storeview each – Retail/Wholesale).

    Have you tried importing images? I’m having issue with image settings. For a product, image for Retail is set properly, but for Wholesale and Default Values, image radio buttons are set to No Image. And even though Retail has radio buttons for images selected, image won’t show up on frontend until I set Default Values image (it won’t build out cache under media/catalog/products/ until I set Default Values).

    I know this is only tagentilly related to your post (mutli-site/multi-store), but if there’s something obvious I’m missing, it would be awesome (I know it has to do with catalog_product_entity_media_gallery – I’ve found a way to update Wholesale via SQL, but not Default Values)

  32. Hey, Great post, thanks a lot! Just a quick question, which bit would be my magento installation directory – just the main folder? Also, will this method work if i want the store fronts to look exactly the same?

    Thanks πŸ™‚

    In your Magento installation directory, make 2 directories called β€œwebsite_1? and β€œwebsite_2?
    Copy .htacces and index.php from your root directory in each of those new directories.

  33. it’s great and help lot.thank.Please give me any solution for one cart and one checkout for multiple websites with multiple store views in Magento.

  34. it’s great and help lot.thank.Please give me any solution for one cart and one checkout for multiple websites with multiple store views in Magento.

  35. If you are running the latest version of Magento you can not bother with creating a new directory and just tick Add Store Code to Urls in system > web > url options!!! Took my hours to find the right blog with this info in.

  36. Dear Tomas, my respect. This multiwebsite topic maybe somehow confusing. Here’s my case: I got a local installation in D:\xampp\htdocs\magento (Windows) which I access from http://www.magentolocal.com (virtual host => DocumentRoot “/xampp/htdocs/magento”). No problem so far. I left Main Website as is and added a new website. I placed the folder “new_website” (htaccess and index) under D:\xampp\htdocs (the same level as “magento” folder); then I copied “../app/design/frontend/base” folder and renamed it as “base_new_website”… that is, set the interface/theme pair for the new website… finally, I set BaseURL to “http://www.magentolocal.com/new_website/”, went to the browser, typed this url and got the magento’s “404 error” webpage. What advise would you give to this dummy beginner? Thanks in advance.

  37. The problem you have is not exactly what this post is about. It’s more about the technical side of setting up multi-website in Magento. As far as I know all Store Views under one Store/Website should display all of your products without any special actions. Editing product in a particular store view just gives you the ability to override the default values with their translations or disable certain products in a particular Store View. So it seems unusual that your products are not visible in other Store Views under the same Store/Website if you haven’t explicitly disabled them.

    As a check-list you may do the following:
    – make sure you are talking about Store Views, not different Websites
    – pick a product that is not visible on German Store View, go into that product in Admin, switch Configuration Scope to German Store View and see if it has Status=Enabled and Visibility=Catalog, Search

    No other setting affect products display on other Store Views within same Store/Website.

  38. @Konstantin i ahve done it but no chnage. but ifi edit a product in german language it will appear. So what i need to do if i need one product to appear in both views.

  39. Clear cache or even better disable it for the setup period (Admin>System>Cache Management), run full reindex (Admin>System>Index Management).

  40. Hello

    I have one main website with one store and 2 store views.

    I have added the products to the store and hope it will be visible in 2 views.

    But here only English page have the products displayed and no products are displayed on German Page.

    I would like to have the products and English Page to be in the German Page too with translation in the name and description

    Please let me whether it possible in Magento.

    Looking forward for your replies as soon as possible as i am stuck upon my project

  41. @jawad – You can’t seriously think I’ll help you to steal from our client? LOL. And yea…this is not forum and this is not support group. Especially not for you!

  42. also i know you already have built the gonabbit and you are the full understanding the system but your team not help me to manage the things but on this forum vistors help me a lot, please apology me if i think wrong and delete this comments
    thanks

  43. Thanks sir, i promise to you i will change though its my client requirments but i will force him to change the things, also am sure you understand that in development mode developer use the dummy things for saving the time , thank you so much for help

  44. @jawad Well, about that… Ok, if you say so…
    However, I find it less likely that somebody would really spent that much time just so he could “change it” once you go live… You even have logo almost identical…well good job…:P

  45. @jawad Trying to copy other people’s design is not very nice. I’m talking about this:
    http://bonaty.com/?___store=arabic&___from_store=default

    Just a friendly advice: If you are having trouble at this point (setting those websites) maybe you should consider to give up. Gonabit is not something you download from magento connect. Thank you.
    P.S. You are literary commenting post on the blog of the people that actually made site you are trying to rip off check this: https://inchoo.net/category/portfolio/

  46. To translate product name, you need to open that product in admin, in the “Choose Store View” selector choose your Arabic Store View, now type in product name in Arabic into the product name field.

    As for the city name, just pass it through translator function like this $this->__($final[…]) and specify Arabic names for possible city values in one of .csv files under app/locale/language.

  47. also city are not translate able please help me , thanks

    <?php echo $final[Mage::getSingleton('core/session')->getCity()]; ?>
  48. @Konstantin
    I LOVE YOU, always keep you in my prayers, you are amazing sir, now problem is solve and i have done the things with your guideness
    thanks sir

  49. Well, have you tried:

    <?php echo $this->__($_description) ?>

    Also, just to make sure you understand how translations work in Magento… The method above will only produce a translated string if that string and it’s translation are present in one of the .csv files under app/locale/your_language/. So if you are trying to translate a custom text, it will not work.

  50. <?php echo $this->__('this text is translatebale') ?>

    this text not translatable , please help , how i can put this to auto translate

    <?php echo $_description; ?>
  51. opps code is not appear

    __('text is autotranslate in this code') ?>

    but which text come with veriable or like this what is not translateable

  52. hi guys, i have fix every thing but problem is which things are in

    __(‘text’); ?>

    that is auto translate or easy to translate with blocks, but which things are in that is not translateable please check the site and help me

    http://bonaty.com/

    in the footer you can change the lang
    thanks

  53. Sorry, missed one bit…

    Yes, I believe that with a combination of and adjusted to RTL theme’s .xml (to reassign blocks to new positions where necessary) and .css (to float and allign elements to opposite sides) files should give you the desired result.

  54. Yes, I believe that with a combination of and adjusted to RTL theme’s .xml (to reassign blocks to new positions where necessary) and .css (to float and allign elements to opposite sides) files should give you the desired result.

  55. @Konstantin
    Thanks for sharing great information, i really appreciate it, and i am trying to implement trick with your help, basically my client need site in 2 lang , big problem is 2nd lang is in RTL ( arabic) thats why i face problem, he want same like this function http://www.gonabit.com/dubai/ in arabic you can see layout change according to arabic lang, i hope now you understand that wat i looking for
    thanks

  56. @jawad
    Most of the settings in Magento can be applied on 3 levels: Global Level – applies to all websites, Stores and Store Views (languages); Website Level – applies to a particular website and it’s Store Views; Store View Level – applies to a particular Store View. In your case you could assign a different design to a German Store View. The term “different design” however does not mean you’ll need to have a full copy of a theme, but only those files from your original theme that need to be different. Let’s say you theme’s CSS is in skin/frontend/default/your_theme/css/styles.css, in that case you will need to make a copy of styles.css and put in into skin/frontend/default/your_theme2/css/styles.css. In Admin go to System>Configuration>Design>Themes. Swith Current Configuration Scope to your second Store View (German language). Type your_theme2 (name of the copy of your original theme) into Skin (Images / CSS) box. Make Sure that Default box has your original theme name in it.

    Now, whichever changes you make to styles.css under your_theme2 will only be reflected in you German Store View. Following the same logic you could make copies of template and layout files.

    This is a big topic that requires understanding of how Magento theme and settings hierarchy works. Hope this helps!

  57. how can i use the mulitpal store with diffrent langues and diffrent view, for eg, 2nd store is german langue but i need some color and layout changes in 2nd sotre, is it possible?

  58. Can my main website have sub websites, with each sub website having its own shopping cart and payment gateway? as well as admin login and reporting capabilities.

  59. Hi,
    In your setup you have English and German in two places. If you enter English product descriptions and titles in global scope, wouldn’t you have to enter the German texts two times?
    One for each storefront?

    Nobody has been able to answer me on this simple question..

    Thanks

  60. @snlaurio,

    I am having the same issue. I am using 1.4.2.x. It seems to load properly (even though it takes a lot longer).

    Here is my setup:

    mydomain.com (default store)
    mydomain.com/wholesale (wholesale store)

    My settings under “Web” are as follows:
    Unsecure:
    http://www.mydomain.com/wholesale/
    {{unsecure_base_url}}wholesale/

    Secure:
    https://www.mydomain.com/wholesale/
    {{secure_base_url}}wholesale/

    I’ve followed the instructions to the “t” on every website thus far and still haven’t been able to get this to work properly. I am simply tring to setup a “Wholesale” store. Can anyone please help? Thanks!

  61. Thanks for your reply and interest, I FIGURED it out YAY. Finaly.

    I Used:
    $mageRunCode = isset($_SERVER[‘MAGE_RUN_CODE’]) ? $_SERVER[‘MAGE_RUN_CODE’] : ‘main_callcenter_view’;
    $mageRunType = isset($_SERVER[‘MAGE_RUN_TYPE’]) ? $_SERVER[‘MAGE_RUN_TYPE’] : ‘store’;

    Mage::run($mageRunCode, $mageRunType);

    and then had my store view configuration links set and now everything works as expected, You have to use the STORE_VIEW_NAME for the CODE and STORE for RUN_TYPE and not the STORE_NAME-code!!! I thought it was the Store-Name and the default view would display.

    this works Perfect now !YAY!

    What I was referring to is exactly like 2 different website-stores either as subdomains or subdirectories, but to have a 2 stores under the same website, or 2 separate store VIEWS under the same website-store, to appear with different and unique subdirectories

    Doman.com / subdir etc…

  62. Leeburstroghm, what exactly are you after? What do you mean by “I need to be able to put a folder to bring up just a different store view”. What is it that you’re trying to achive? Do you want to assign existing Store Views to a different Store in your installation, or do you want your Store Vies to be accessible on different URLs?

  63. Well, I have 2websites each with a single store and view.
    http://GlucALite.com the main store, and another at a folder.

    I REALLY really need to be able to put a folder to bring up just a different store view, so I have one website, one store and multiple store views. to get rid of the second store. how do I do this??!

  64. I can’t get the second site /wholesale to show up with a theme. It’s not even picking up the defualt theme. Please what am I doing wrong?

  65. Hello,
    I am going to develop a website for multiple store[each store has its own separate domain name] with single shopping cart. So that user can see all added products in cart at any website [in cart all other website added product will also show].
    Can anyone please help me to develop that system in magento1.4
    I need urgently. If some one explain with code in steps then its good to me.

    Many thanks in advance….

  66. Correct me if I am wrong, but I believe “add store code to url’s” is a global setting, that you can not override within one installation. So you’ll either have to “hack” you way through or use another instance of Magento. If you do find a nice hack for this, please share!

    Good luck.

  67. i have installed magento om my primary domian like Maindomain.com/ now the url of this main domian is Maindomain.com/StoreviewCode/Category/SubCategory.its fine for me. now i have also create a another add on domain def.com on server.now how can i make the url for this add on domin like def.com/Category/subcategory i dont want to include this StoreviewCode in add on domain url.please provide the solution how can i do it..thanks so much

  68. Hi,
    Can you please update this for v1.4.1 – I’m in the process of doing this and i just can’t see to get a break on how to do it.
    Will appreciate it great deal if you could help.

    Thanks

  69. Hi – with multiple stores, can you filter orders by store in the admin section? This seems like it would be critical for reconciliation.

    Thanks

  70. Hi Konstantin,

    Finally I figured out what’s wrong.
    I disabled redirection in cPanel, then I wouldn’t be redirected to my primary domain when I visited the addon domain.

    Thanks a lot my friend!

  71. Hi Konstantin,

    I have sent an email ” Re: Atman’s magento store ” to you. Please have a check.
    Thanks for your time my friend.

  72. Hi Konstantin,

    I used magento 1.4.

    And yes, both primary domain and addon domain have the same document root: /public_html/

    Now I will still be redirected to my primary domain even when I visit the addon domain.

    It’s really frustrating!

  73. In you example “website_1” is an id/code of either website or store_view, so the second variable tells the system to look for a website with this code. Optionally you can pass “store”, so that system will load store_view with given id/code.

    That way you can have either a website or a language (store view) on a different url/domain, and whenever anyone goes to that url, Magento will load appropriate store view or website.

    Hope this helps πŸ™‚

  74. Sorry, should clarify. I understand that website_1 is the name of the subdirectory. It’s ‘website’ I’m not sure about.

  75. … dumb question here… When you say Mage::run(‘website_1’, ‘website’);
    does one use the word “website” or is that supposed to be a path?
    Thank you, Inchoo people!

  76. You need configurated base links for new website:
    System-Configuration-Web. Select New shop in the left drop-down menu and edit unsecure and secure fields.

  77. i have 1.4 magento
    i made everything working with subfolder /wholesale store
    the /wholesale is opening but without theme. i want the default theme for that store too. do i miss something?

  78. Thanks @konstantin, I found the same. I couldn’t get the .htaccess method to work, though I do wonder if it’s because I’m using the ServerAlias directive in my apache vhosts.

    @Tomas, fair enough, good to know. The solution that @konstanin and I have working don’t need different sub-dirs which is much cleaner.

    Next challenge is to migrate 1.3.2 phtml mods into the 1.4.0.1 theme files, ahh backwards compatibility…

  79. I’ve recently set-up Magento 1.4.0.1 to run two websites on two separate subdomains, but this would also work nicely for different domains as long as they are hosted on the same account.

    Assuming you have already created another website in Magento config… First thing to do is to point both of your subdomains/domians to the same document root in your hosting settings, so that they both load your Magento Home Page. All other pages will be loading with your primary domain in url – this is how it should be.

    Next, 1.4 tutorial for multiple websites tells us to either use Virtual Host (which I did not have) or .htaccess method (which did not work for me either), but I used this piece of code in my index.php and it worked like a charm:

    if ($_SERVER[‘HTTP_HOST’] == “sub.mydomain.com”){
    $_SERVER[“MAGE_RUN_CODE”] = “website_code”;
    $_SERVER[“MAGE_RUN_TYPE”] = “website”;
    }

    repeat this for every website you have and place it right before:

    $mageRunCode = isset($_SERVER[‘MAGE_RUN_CODE’]) ? $_SERVER[‘MAGE_RUN_CODE’] : ”;
    $mageRunType = isset($_SERVER[‘MAGE_RUN_TYPE’]) ? $_SERVER[‘MAGE_RUN_TYPE’] : ‘store’;

    Then also go and set Base URL in Magento config to match your domain/subdomain.

    Clear Cache and try opening both (or more) of your websites in browser.

    Hope this helps!

  80. Yaaaay! Finally I got it working in some form! However this does not work with SEF URLs turned on πŸ™ Any clues how to get it working and still have nice looking urls?

    Also would be great to see a description of Magento 1.4 specific method for both subdirectory and subdomain cases.

  81. Great post.

    I’d like to see the way to do in magento 1.4. I’ve read in the magento’s wiki site though, but it didn’t work because i’m confuse that wether should i create new index.php and .htaccess or not?

  82. @Igor, yes, U R right, since 1.4 things are done differently.
    Thing is that described method works 1.3 AND on 1.4 so I decided to write article that way πŸ™‚

  83. This is a nice summary on how to setup a magento multistore. If I see it right this is for magento 1.3.x.x version.

    I’m not sure if I got it right from the documentation on the internet, but since version 1.4.x.x. what you have to change in the index.php file is
    $compilerConfig = ‘includes/config.php’;
    and/or ( depending on the server/hosting package you have )
    $mageFilename = ‘app/Mage.php’;
    to the right path and add your store code to this line
    $mageRunCode = isset($_SERVER[‘MAGE_RUN_CODE’]) ? $_SERVER[‘MAGE_RUN_CODE’] : ”;

  84. Great article. Something I will refer to again.

    I spotted a suspect typo:

    Should it be GERMAN for the (B) examples?

    1) a) Website 1 (code: website_1) – Website Store 1 – English Store View (code: english_store_view_website_1)
    b) Website 1 (code: website_1) – Website Store 1 – GERMAN Store View (code: german_store_view_website_1)

    2) a) Website 2 (code: website_2) – Website Store 2 – English Store View (code: english_store_view_website_2)
    b) Website 2 (code: website_2) – Website Store 2 – GERMAN Store View (code: german_store_view_website_2

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.