Multiple Storefronts with Magento
This article provides instructions on setting up multi-store functionality in Magento. Once you have created your new store, you can choose from either of the two different methods presented in this article 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:
- Log in to the Magento Admin Panel.
NOTE: If you want your stores to share the same catalog and products, you may skip to Step 7. - In the top menu, go to Catalog > Manage Categories.
- Click Add Root Category.

- In the Name field, enter your new store name.
- Under Is Active, select Yes.
- Go to System > Manage Stores.

- Click Create Website.
- In the Name field, enter your new store name.
- In the Code field, enter a unique string without spaces, and then click Save Website.
NOTE: This code will be used later, so be sure to write it down.

- Click Create Store.
- In the Website field, select the website that you just created.
- In the Name field, enter a name for your store.
- In the Root Category field, select the Root Category that you created above or use the default Root Category if you skipped ahead. Click Save Store.

- Click Create Store View.
- In the Store field, select the store you just created. In the Name field, give your view a name (typically "English").
- In the Code field, enter a unique string to identify the store view. Change the Status to Enabled. Then click Save Store View.

- Go to System > Configuration.
- In the Current Configuration Scope, select the website that you just created.

- Select the Web menu option, and then click to expand the Unsecure and Secure sections, respectively.
- For each section, clear (deselect) the Use Default box next to the Base URL and enter the URL for your store, including the trailing slash. When you are done, click Save Config.

- 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 article to create a Secondary Domain for your new store:
How to Create 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/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)
IMPORTANT: These instructions will work only for Magento versions 1.4.0.1 and greater.
- Ensure that the domain name that 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 Create 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 set up 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 text just 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]

