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

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

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 (“”)
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 “” from dropdown menu.
For Name: I like to enter same as website (“”) 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 “” 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 (“”)
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:

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 (“”)
Go to Web tab and under Secure and Unsecure you need to modify:
Base Skin URL (example:
Base Media URL (example:
Base JavaScript URL (example:

That’s it.
Enjoy coding!

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

Emulate store in Magento Ivan Weiler
Ivan Weiler, | 3

Emulate store in Magento


  1. Please help.
    i have 2 websites.
    i want to add products in and show products in
    How can i do this?

    1. You can do that by going to the specific product in admin, then go the the websites tab and then select on which website should the product be visible.

  2. Hey,

    I am facing an issue with the URLs.

    I have created two websites under magento en and pl with the same store code and folder names under magento root.

    Now I want to run

    Home pages are working fine but inner pages are not working. Giving 404 error.

    if I try to run like then it works. Please help me.


  3. I want to configure website for multi country – multi currency.
    e.g. For USA /Canada , i want to set
    Select country – USA , Currency should auto switch to $ from base currency.
    But product should should be limited compared to base website. Means limited products for country. How to configure please guide me..

  4. Is there anyway to have a separate payment method for the 2nd store? Right now it’s all configured in the default configuration and I’d like the 2nd store to have it’s own payment methods.

  5. Is any possibility that we can create multiple websites only but use on default store. i need to create multiple website due to different url but i want to use same stores. when i create multiple stores and then data is double in quite huge amount is any kind of solution some one implement do let me know. thanks

  6. Is there any limit of web-store creation? I need to create atleast 20000 webstore. Please suggest.

  7. 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

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

  9. 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

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

    after launching these i have lost totally seo ranking of my old domain

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


  10. 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

  11. localhost/magento/shoe

    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

  12. 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?


  13. 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

  14. 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

  15. 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?

  16. I have the following setup in magento

    One magento install with several domain aliases.

    #Mage::run($mageRunCode, $mageRunType);
    switch($_SERVER['HTTP_HOST']) {
    	// Website A
    	case '':
    	case '':
    	// Website B
    	case '':
    	case '':

    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?

  17. 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.

  18. RotorRian – it should be like this:

    SetEvnIf Host ^www\.store.visionup\$ MAGE_RUN_CODE=basecode MAGE_RUN_TYPE=website
    SetEvnIf Host ^www\.hidreplacements\$ 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”

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

    Hey Ivan if I 2x websites on magento and what would my htaccess be because i keep on getting and internal server error ????

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

    Is this correct ?????

  20. 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

  21. 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

  22. @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.

  23. @ 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 and 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?

  24. 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
  25. 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 then will be initialized website with code “website_one_code” and if domain name is 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> <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.