How to set multiple stores/websites with one magento installation on different domains

Featured Image

This article will describe quickest way how to use and configure one Magento installation on different domains.
Point here is what do you want to have on that different domains, for example you want to have chosen categories/products on one domain and the other one will be on different language.
First you figure that and then go to configuration.

So for each domain you need to create webiste in main Magento admin installation:
System > Manage Stores > Create Website

For Name: you enter name of you desired domain (“my.website.com”)
For Code: you will enter identifier for that domain (“my_website_com”)

After that you will go to:
System > Manage Stores > Create Store

For Website: you will select “my.website.com” from dropdown menu.
For Name: I like to enter same as website (“my.website.com”) so I know for which website this store is but you can put here whatever you want.
Now for the Root Category: if you whish to have different menu for that website you will need to create new root category under
Catalog > Manage Categories > Add Root Category
in which you will put categories for that website.

And in the end you need to setup Store View under:
System > Manage Stores > Create Store View

Under Store: select “my.website.com” from dropdown menu.
For Name and Code enter “my_website_com”
And for Status: “Enabled”

If you wish to have diiferent language on that wesite you will need to change that on
System > Configuration
Under Current Configuration Scope: select your website/store from dropdown (“my.website.com”)
Under General tab go to
Locale Options and for
Locale choose language from dropdown (don’t forget to install language pack).

To run Magento on your different domain you need only two files:
.htacces
index.php

Open “index.php” and modify line which begins with “$mageFilename”
so it goes something like this:

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

and line:

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

replace with:

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'my_website_com';

Now you will also need media, skin and javascript files so you can also copy them into root folder of your new domain or you can set it from Magento admin:
Under Current Configuration Scope: select your website/store from dropdown (“my.website.com”)
Go to Web tab and under Secure and Unsecure you need to modify:
Base Skin URL (example: http://real.website.com/skin/)
Base Media URL (example: http://real.website.com/media/)
Base JavaScript URL (example: http://real.website.com/js/)

That’s it.
Enjoy coding!

Interested in hiring us?

Have a chat with us. You would be surprised how small changes can make your business even more successful.


32 comments

  1. Same problem as niranjan has. Mike, where you add that code? I added to index.php and got error. Fatal error: Class ‘Mage’ not found in /home/profitel/public_html/index.php on line 12

  2. i have create multiweb site in magento 1.5 but when i click on any links it redirect in original site.

  3. Hi, i have problem with my newly added domains because i have launched three more site recently and i have lost my old site ranking from google,

    i have following domains,

    old domain
    http://www.abc.com

    new domains which i have launch last two months ago which are

    http://www.abc.us
    http://www.abc.fr
    http://www.abc.in

    after launching these i have lost totally seo ranking of my old domain http://www.abc.com

    please help me out, my website is based on magento platform only.

    Regards,
    Manzar

  4. I am going to create multi language website in Magento. Store language dropdown is showing well in the frontend. Language also convert nicely once I change the store language. My only concern is whenever I click to another link suppose aboutus.html store language automatically change to default (English). Anyone help me. Thanks in advance

  5. How Should I configure my home page for different website running under same domain..

  6. localhost/magento/shoe
    localhost/magento/furniture
    localhost/magento/computer

    I have created store for individual website.

    I know the login option of the 3 website will be the same.I dont have to make different login box.

    just for example:

    When I go :localhost/magento/shoe
    there will be a login option.
    Any customer go to that site and he can registered as well he can entered into the the shoe website.

    Similar way for next two the same case will occur.
    So here we dont need to make different login boxes.

    Upto that section i have done.

    Now there is requirement to have a Retail Shop:
    Under localhost/magento(Which is the main domain) there will a section for retailer to create an account and to login into his account.
    This retailer has the option to control above all 3 website as mentioned above.

    I want another login option for this retail shop.
    How can i do that.Please guide me

    If you still have doubt then please let me know… Thanks in advance

  7. Hi,

    We’re contemplating multiple websites under one installation of Magento. Are there any websites that you know which have multiple websites/ stores under one single Magento installation?

    Thanks.

  8. Hi Guys,

    I am able to setup up Multi Store correctly and they work fine but one issue, both the stores are using same theme, I need have a different theme for second store. Is it possible. if yes, please do let me know how?

    Any help will be appreciated.

    Vikram R

  9. Hello Everyone

    I have a problem. I am looking to setup on Magento 1.7,, two domains each in a differnet language but i want to sell the same products from the same catalog.

    Is that possible or do i have to setup one domain with two different languages. the reason for setting up two domains is that they are different for different countries. but i am seelling the same thing.

    Please help

  10. i create website and stores as you told the steps
    but where to copy the .htaccess file and index.php file for another website in magento installation?

  11. I have the following setup in magento 1.4.1.1.

    One magento install with several domain aliases.

    #Mage::run($mageRunCode, $mageRunType);
    switch($_SERVER['HTTP_HOST']) {
    
    	// Website A
    	case 'websiteA.com':
    	case 'www.websiteA.com':
    		Mage::run('websiteA');
    	break;
    
    	// Website B
    	case 'websiteB.com':
    	case 'www.websiteB.com':
    		Mage::run('websiteB');
    	break;

    Multistore runs perfectly without editing .htaccess

    Users can switch languages with the language switcher and stores with the stores switcher.

    However cart sharing and login sharing does not work.

    Can anybody help me with this?

  12. We need a single sign in between different stores in one installation. Is there a solution for this? We already use the Account sharing options for sharing userdata.

  13. RotorRian – it should be like this:

    SetEvnIf Host ^www\.store.visionup\.co.nz$ MAGE_RUN_CODE=basecode MAGE_RUN_TYPE=website
    SetEvnIf Host ^www\.hidreplacements\.co.nz$ MAGE_RUN_CODE=altcode MAGE_RUN_TYPE=website

    You don’t need to put your domain name on the end. It actually has to say “website”

  14. WOW !!! at least some decent info on this topic !!!!

    Hey Ivan if I 2x websites on magento

    http://store.visionup.co.nz and
    http://www.hidreplacements.co.nz what would my htaccess be because i keep on getting and internal server error ????

    SetEvnIf Host ^www\.store.visionup\.co.nz$ MAGE_RUN_CODE=basecode MAGE_RUN_TYPE=www.visionup.co.nz
    SetEvnIf Host ^www\.hidreplacements\.co.nz$ MAGE_RUN_CODE=altcode MAGE_RUN_TYPE=www.hidreplacements.co.nz

    Is this correct ?????

  15. Hi Vedran,

    This is very informative post, and I did something like this for one of my clients. But I didn’t changed skin, media, and js paths.. only url.

    One problem I have, and I was thinking of asking here.

    Each domain have its root category and user for adding new products. But user from one domain can edit products and categories from another domain

    Is there a way to separete this permision issue ?

    Thanks for providing great magento resource for community

  16. it work very well but don’t forget that “Redirect to Base URL if requested URL doesn’t match it” must be at false in Système/Configuration/ defaultshop web

  17. @Si Parker,

    Magento allows you to run absolutely different websites with different configurations via single point just by specifying Magento’s internal website code. So it means that if you configure your domain configuration and webserver configuration to manage two different domain names on the same server directory, then Magento will parse request and show up different Magento website instances depends on .htacces rules.

  18. @ ivan. correct me if am wrong here but what is the point in putting multiple domain instructions into a single htaccess file?

    if i have domain1.com and domain2.com wont they need to be setup on separate hosting in order to resolve properly?

    in which case only the one htaccess entry needs to be made?

    or is there a way to send all of the different domain requests to one place at which point the correct store is then delivered?

  19. Sorry, there are typos in my previous comment, replace “^” character with “$” in at end of strings like “domain1\.com^”
    so it should be

    SetEvnIf Host ^www\.domain1\.com$ MAGE_RUN_CODE=website_one_code MAGE_RUN_TYPE=website
    SetEvnIf Host ^www\.domain1\.com$ MAGE_RUN_CODE=website_two_code MAGE_RUN_TYPE=website
  20. Since Magento 1.4.x you don’t need to copy index.php file in Magento to run a different website. All of them can be easily handled with .htaccess rules by setting up environment variables.

    For example:

    SetEvnIf Host ^www\.domain1\.com^ MAGE_RUN_CODE=website_one_code MAGE_RUN_TYPE=website
    SetEvnIf Host ^www\.domain1\.com^ MAGE_RUN_CODE=website_two_code MAGE_RUN_TYPE=website

    These lines of code checks Host header in HTTP Request. In this case if domain name is http://www.domain1.com then will be initialized website with code “website_one_code” and if domain name is http://www.domain2.com then will be initialized website with code “website_two_code”.

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> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.