How to Multiple Websites Magento 1.4

Today im going to expain you how to setup multiple websites in a single Magento installation.

I was getting crazy trying to solve this. Finally I found the solution.

After create the X Websites you need from your Admin section we hace to edit a piece of code.

Note: each Website has one unique Store and one unique Store View.
Note2: use short and easy Websites codes, we will need them now.

Sub Domain Method

In your Index.php file (in the root directory of the Magento installation) you have to look for:

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; Mage::run($mageRunCode, $mageRunType);

Then replace the found code for this new one:

// this first line detects the domain / sub domain switch($_SERVER['HTTP_HOST']) { case '': /* store1 is the code you wrote in the admin when created the website */ Mage::run('store1', 'website'); break; // (default store) default: Mage::run(); break; }

Sub Directory Method

Using a Sub Directory means more job.

First of all you need to create as much as directories you wanna have.



So following the example you will create 2 directories in the root of your magento installation.

Now you have to copy & paste the index.php and the .htaccess to those folders.

Once that we need to edit the index.php.

Look for:

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; Mage::run($mageRunCode, $mageRunType);

And replace it for:

// this will force to load the Website with the code store1 Mage::run('store1', 'website');

You need to repeat this step to every folder, to every index.php you created before.

Now check out this screenshot to see how to configure the Website:


Now you know how to create multiples Websites in one Magento Installation.

Any questions or ideas, post a comment πŸ˜‰

  • Hi,

    I am having trouble setting up 2 webstores in magento 1.4.

    I have magento installed at I wish for to point to the default website on magento and for to point to store2 which I have setup on magento admin. I have followed your instructions for subdomains but do not understand how the subdomains redirect to the correct stores?

    Sorry, I am completely new to php and Magento.

    Any help would be great.

    Thanks, James.

  • hi,

    I’m having trouble understanding creating multiple website on a single installation of magento 1.4(the latest)

    It seems so simple in magento 1.4 rather than the older version.

    I have and
    My magento installation is in
    I want to create another website/store in and I have to create it’s own folder. In older version of magento, we have to put .htaccess and index.php in it. In 1.4, should we have to create
    the files?


    • Hey bare,

      You have to follow the Sub Domain Method part of the post above.

      You have to replace those lines in the index.php

      Hope that helps.


  • Is there a way to search in all the store when you create more then 1?

    This is the only problem i’m facing right now…

    • Hi Wladimir,

      I don’t think is posible to search products in diferent stores from 1 store.

      So.. Why having more than 1 store when you want to share product listing?

      • Actually because we run a large print office and each category is also a subdomain so we got one main shop and all the categorys are shops too.

        SO if you search we want user to search in alle of our departments…

        because meganto doesn't let us use the rewtite engine as we want to…

        that should be the most powerfull way….but there's now way for that

  • Actually because we run a large pritn office and each category is also a subdomain so we got one main shop and all the categorys are shops too.

    SO if you search we want user to search in alle of our departments…

    because meganto doesn’t let us use the rewtite engine as we want to…

    that should be the most powerfull way….but there’s now way for that

  • Hi,
    i have magento installed on two sites. Can i have a common shopping cart for them using the multiple store method stated above?

    • I hope I understood your question.

      No, having multiple websites you can not buy from 2 websites in the same shopping cart.

      You have to buy the red shoes from the Shoes Store and the white car from the Car Store.

      Hope that helps.


  • Hi quicoto,
    If i setup multiple stores in my magento, then the shopping cart will be same for all the stores, right?

    • Hi thewhiz,

      I just tested in my local Magento now.

      Yes, both “stores” (not Websites) share the shopping cart.

      So if you add 1 product from Store 1 and you switch to Store 2 you will see that item in your cart πŸ˜‰


  • Hi,

    thanks for the tutorial but I still cannot figure it out … I have the main Magento installation in root and want to add second website in subfolder /wholesale.

    I copy index.php and .htaccess into the subfolder. Edit index.php and follow your tutorial … however, when I want to access the new store in /wholesale I am getting app/Mage.php error.

    If I change the path to ../app/Mage.php I will get the actual store with correct theme but every link goes to 404 … am I missing some crucial htaccess setting? Redirects?


    Update: I think I got it working by simply adding RewriteBase /wholesale/ into the .htaccess file … will test it now …

    • Hi Yara,

      Are you using magento 1.4 version? I think this does not work in the 1.3 or older.

      About the .htaccess I didn’t modify anything.

      If you find the solution, please let me know πŸ˜‰

  • Hi Quicoto,

    I am using 1.4 version …

    so far the combined solution of your tutorial and changing the path for mage.php together with Redirect rule in htaccess file works for me … I need to test it more and will let you know …


    • i am using 1.4
      i follow the tutorial with the /wholesale directory but is giving me error “app/Mage.php was not found”

      quicoto can you tell me if you got it working ?

  • i found it.
    in the index.php you need to change all the folders path to ../paths instead of /paths

    I have some problems with the theme but i ll found out :))

  • i have a problem in my /wholesale is not appearing to have any theme.
    i tried a few things but still not appear anything!
    is there anything i missing?
    i want to use the same theme as the main site.
    Should i copy anything to the /wholesale subfolder?

    • I guess “/wholestore” is the subfolder you created as a new Website, right?

      No you don’t need to.

      I think it’s something with the thing you changed before “../” and “/” relative paths.

      I could help you more deeper if I see some code. maybe you can open a new Topic in our forum and paste some code from your index.php

  • this is the code…
    the directory i created is “/wholesale”

    if (version_compare(phpversion(), '5.2.0', '<')===true) { echo 'Whoops, it looks like you have an invalid PHP version.Magento supports PHP 5.2.0 or newer. <a href="<a href="" rel="nofollow ugc"></a>; rel="nofollow">Find out</a> how to install Magento using PHP-CGI as a work-around.'; exit; } /** * Error reporting */ error_reporting(E_ALL | E_STRICT); /** * Compilation includes configuration file */ $compilerConfig = '../includes/config.php'; if (file_exists($compilerConfig)) { include $compilerConfig; } $mageFilename = '../app/Mage.php'; $maintenanceFile = 'maintenance.flag'; if (!file_exists($mageFilename)) { if (is_dir('downloader')) { header("Location: downloader"); } else { echo $mageFilename." was not found"; } exit; } $ip = $_SERVER['REMOTE_ADDR']; $allowed = array('β€²,''); // if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) { $basePath = dirname($_SERVER['PHP_SELF']); include_once dirname(__FILE__) . '../errors/index.html'; exit; } require_once $mageFilename; #Varien_Profiler::enable(); if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) { Mage::setIsDeveloperMode(true); } #ini_set('display_errors', 1); umask(0); // this will force to load the Website with the code store1 Mage::run('wholesale' , 'website');
    • I think is something with

      $compilerConfig = 'includes/config.php';

      If you remove the “../” does it work?

  • nothing change when i do that

    • Did you changed all the things inside the .htaccess?

      In that post you’re linking says something about RewriteBase

      Last time I did was everything fine.

      Don’t know how to help you, sorry.

  • the problem was in configuration/web
    (wholesale skope) at the top

    it was {{unsecure_base_url}}skin/ and i made it

    its working now proberly!

  • that’s why i am going crazy some times with programming πŸ˜›

  • Hey, I followed your tutorial and I’m still getting a problem, when visiting a subfolder, I get to see my other website’s menu as I should, but all the links end me up on a 404-page with the menu of the default website. Also edited the .htaccess but that didn’t change anything …

    Can the problem be in the structure I’m using, since this is a subfolder in a subdomain? => Default store => Second store

    This isn’t the final set up for domains, just for testing purposes …

    • Perhaps is not posible.

      I didn’t test that far.

      The 404 error, like you said, looks like .htaccess issue.

  • Hi quicoto,

    I’ve been spending a couple of hours trying to find a solution for my problem, and I’ve been directed to your page for a solution…

    Based on your example above, you’re creating multiple websites by using subdomains, but would one be able to set up multiple websites using different domains.

    For instance:

    Base Store:
    Website 2:

    Your help will be much appreciated.

    Thanks in Advance!


    • Yes of course.

      Playing with Sub-Domains or Domains is exacly the same.

      You just need to point all your domains to the same directory (root folder).

      Let me know if you could make it πŸ˜‰


  • Failman here!,

    Thank you quicoto, I finally got it to work. I was having one of those fail moments where I forgot to change the Base URL to the store I was pointing to.

    So I had to change the Base URL to match my domain name…. and voila! πŸ˜€

    Thanks Again!

  • Hi,

    I am having a hard time!!
    I have used the sub-domain method and created and followed the instructions but this is what I get:

    a:5:{i:0;s:121:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'books_working.catalog_category_flat_store_10' doesn't exist";i:1;s:5428:"#0 /home/books/public_html/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
    • The first line shows the error:

      Table 'books_working.catalog_category_flat_store_10β€²

      Have you created the stores in your backoffice properly ?

  • Hi

    If you get an error like “app/Mage.php was not found”, don’t worry

    If you have created some subfolders as described on top, you have also to modify line 45 in each index.php to the right path. For subfolders, it is fine to change it to: “$mageFilename = ‘../app/Mage.php’;”
    Look at the “../” that means one directory up.

  • Hi everybody,

    I am redirected here in searching solution to multi domain, multi store setup.
    Background info:
    Magento 1.62, WAMP server,
    magento installation directory : c:\wamp\www\magento6
    virtual hosts :
    My setup looks like this:

    DocumentRoot “c:/wamp/www/”
    ServerName localhost:8080

    DocumentRoot “c:/wamp/www/”
    ServerName mag-dev.local

    DocumentRoot “c:/wamp/www/”
    ServerName aki.local

    DocumentRoot “c:/wamp/www/”
    ServerName classi.local

    in c:\windows\system32\drivers\etc\hosts mag-dev.local aki.local classi.local

    in magento6/.htaccess I added the following lines:

    SetEnvIf Host www\.aki\.local MAGE_RUN_CODE=aki_local
    SetEnvIf Host www\.aki\.local MAGE_RUN_TYPE=website
    SetEnvIf Host ^aki\.local MAGE_RUN_CODE=aki_local
    SetEnvIf Host ^aki\.local MAGE_RUN_TYPE=website

    SetEnvIf Host www\.classi\.local MAGE_RUN_CODE=classi_local
    SetEnvIf Host www\.classi\.local MAGE_RUN_TYPE=website
    SetEnvIf Host ^classi\.local MAGE_RUN_CODE=classi_local
    SetEnvIf Host ^classi\.local MAGE_RUN_TYPE=website

    in magento admin, I created websites
    website: aki.local
    store : aki.local
    storeview: aki.
    Store * aki.local Store* aki.local
    Name * english Name* german
    Code * aki_en Code* aki_de
    Status * enabled Status* enabled

    likewise setup for classi.local website.

    For current configuration scope aki.local in cofiguration/web/unsecure
    BASE URL: http://aki.local:8080/magento6/
    BASE SKIN URL: http://aki.local:8080/magento6/skin/
    BASE MEDIA URL: http://aki.local:8080/magento6/media/
    BASE JAVASCRIPT URL : http://aki.local:8080/magento6/js/

    likewise setup for classi.local website

    I have copied the themes in appropriate places:
    magento6/app/design/frontend/default/aki for theme aki
    magento6/app/design/frontend/default/classi for theme classi
    magento6/skin/frontend/default/aki skin for aki
    magento6/skin/frontend/default/classi skin for classi

    I have created CMS pages
    title: aki-home
    URL-key : home

    title: classi-home
    URL-key : home

    title: home page the default website/store
    URL-key : home

    for aki.local in system/configuration/web/default pages
    CMS Home Page: aki-home.

    for classi.local in system/configuration/web/default pages
    CMS Home Page: classi-home.

    for the default store, the themes are loaded and working well.
    for the http://aki.local:8080 or http://classi.local:8080, the themes are not loaded.
    I only see the websites without themes.
    how do I tell magento to find the themes for aki.local and classi.local? Do I need create some folders for the new websites?

    I would appreciate your answers.

  • strangely, it works now.

  • yes more topics about this πŸ™‚ I have the same issue as multiple people here. I have setup everything but somehow he still doesn’t see the correct js / css / media folders. Getting so crazy about this.

    I am trying the subfolder option, changed the index file, changed the secure / unsecure url changed the media js links to be absolute etc etc etc

    Anybody who could help me?

  • i have the same problem like sander, i did everything, looked on every tutorial i can lay my hands on, done exactly every step here, yet nothing, the /app/mage.php still haunts me !!!
    i am currently running magento 1.7

    please do help me cause i am lost

  • That’s a great article. However, I have found people also want the guide on multi-store in Magento 2. Here’s a guide that can help them:

Leave a Reply

Add <code> Some Code </code> by using this tags.