Multiple Storefronts with Magento
This tutorial will show you how to set up multi-store functionality in Magento. Once you have created your new store, there are two different methods presented for implementing multi-store functionality at the server level:
- Separate Directories for Each Store (Using Secondary Domains)
Works for all versions of Magento. - Shared Directory for All Stores (Using Pointer Domains)
Works for versions higher than 1.4.0.1.
Step 1: Create a New Store in Magento
The first step in setting up multi-store functionality is to create the new store(s) in the Magento Admin application. Follow the steps below to create a new store:
- Login to the Magento Admin Panel.
NOTE: if you want your stores to share the same catalog and products, you may skip to step 6. - Go to Catalog→Manage Categories in the top menu.
- In the Name field, enter your new store name. Under Is Active select Yes.
- Click Create Website.
- Click Create Store.
- Click Create Store View.
- Go to System→Configuration.
- Select the Web menu option, and expand the Unsecure and Secure sections by clicking them.
- You have successfully setup a Magento store. Repeat the steps above for any additional stores you wish to create.
Step 2: Configure the Server to Load the New Store
Now that you have your new store created, you need to configure the server to load the right store. There are several methods for doing this. We present the two most popular methods below. The first method is the older of the two, and will work for any version of Magento. The second method takes advantage of changes made to the index.php file introduced in version 1.4.0.1.
Method 1: Separate Directories for Each Store (Using Secondary Domains)
- Ensure that the domain name you wish to use is pointing to the server.
- Use the following guide to create a Secondary Domain for your new store.
How to add a Secondary Domain - Using either FTP or SSH, copy the .htaccess and index.php files from your Magneto Installation to the document root of your new domain.
- Open the index.php file that you just copied over and edit the last line of the file as follows
NOTE: change newstore to the Code you wrote down when you created the new website above.
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/404/ 404 # this is only in 1.3x 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/reports/ reports # this is only in 1.3x ln -s /home/example/example.com/html/skin/ skin ln -s /home/example/example.com/html/var/ var
- You have successfully setup your secondary domain to work with Magento. You may now load your new domain in your browser and begin developing your new store.
Method 2: Shared Directory for All Stores (Using Pointer Domains)
NOTE: These instructions will only work for Magento versions 1.4.0.1 and greater.
- Ensure that the domain name you wish to use is pointing to the server.
- Use the following guide to create a Pointer Domain for your new store:
NOTE: the Pointer Domain will be pointing at the Primary Domain where your Magento Installation is located.
How to add a Pointer Domain - Edit the .htaccess file in the document root of your Magento Installation and enter the following just above the line RewriteEngine On:
- Ensure that .*newstore.* matches the domain name of your new store.
- Ensure that MAGE_RUN_CODE matches the Code you wrote down when you created the new website above.
SetEnvIf Host .*newstore.* MAGE_RUN_CODE=newstore SetEnvIf Host .*newstore.* MAGE_RUN_TYPE=website
- You have successfully setup your pointer domain to work with Magento. You may now load your new domain in your browser and begin developing your new store.
Addendum: If SetEnvIf Doesn't Work
On some servers, particularly those running Litespeed Web Server, the SetEnvIf directive does not get recognized in the .htaccess file. If you are trying to set up multiple storefronts using Method 2 above, and it doesn't seem to be working, try the following:
- Edit the .htaccess file in the document root of your Magento Installation.
- Enter the following right below the line #RewriteBase /magento/:
- Ensure that .*newstore\.com matches the domain name of your new store.
- Ensure that MAGE_RUN_CODE matches the Code you wrote down when you created the new website above.
RewriteCond %{HTTP_HOST} .*newstore\.com [NC] RewriteRule .* - [E=MAGE_RUN_CODE:newstore] RewriteCond %{HTTP_HOST} .*newstore\.com [NC] RewriteRule .* - [E=MAGE_RUN_TYPE:website]








