Setting up a multi-website Magento store

Though there is a lot to learn, understanding the file structure of Magento is essential in order to migrate a store into a multi-website for an upgraded store. Here is an overview of the steps to migrate a second store into Magento.

Last year I had the opportunity to learn about working in the e-commerce platform Magento–creating products, adding modules, updating security patches and more. Though there is a lot to learn, understanding the file structure of Magento was essential in order to migrate another store (running version 1.4) into a multi-website for another store that had been recently upgraded to 1.9.2. While searching for the best process, I learned there are many ways to set up a second store on the same Magento install—but there were many things I still didn’t understand being the novice server administer of a one-person web team.

Below is an overview of the steps I took to migrate a second store into Magento; please note that this is not an exhaustive list but an overview to point you in the direction of which parts you may need to learn more about.

Add second website to Magento

There are many guides that cover this including How To Setup Multiple Stores On Magento. Be sure to understand the difference between a website, store and language. Separate websites can reference the same products and CMS pages, but they are typically used for completely different product catalogs. Set up your categories and website from the store settings, keeping the website code in mind, as you will want to make this consistent in your settings. Try it out now and set up your second store.

Modify server to accommodate multiple Magento websites

To me, the most daunting part of adding a new website to an existing Magento install was the fear of making an error that would take down the current website. After testing with local web servers, here are the steps I took on our Apache server (running Debian 7×64):

Update DNS settings

From your second domain (or a test domain) update the CNAME/A name to point to the server address of your primary Magento website. For example, my setup looks like this:

Store2 Advanced DNS (A Records)

Host TTL Numeric IP
www 7200 192.168.x.x
@ (None) 7200 192.168.x.x
* (All Others) 7200 192.168.x.x

Add to your virtual hosts

Add your second domain to sites-available on your server. Once you are satisfied with the setup, you can run aen2mod enabled, to enable to the second domain on your server. Ensure your server is using Named Virtual Hosts.

Test apache server config prior to restarting:

  /usr/sbin/apachectl configtest


  sudo service apache2 restart

Update primary website web files

In order to use shared themes between websites with minimal changes, it is best to centralize any settings that are the same between your websites, and only override the default themes as necessary using a local theme. I found it easiest to copy the local theme, rename it to match your website id and update the styles and HTML only when needed.

Support secondary website and multiple themes

Copy the local design files (which override your default design theme) and rename the copied folders to match your website code.

  • app\design\frontend
  • skin\frontend
  • skin\frontend\THEME

Redirect incoming requests to the appropriate store

When typing in your primary or secondary website URL, the server must have a way to decide which files to use. In addition to the updates you made when setting up your second website, you must include web store codes in your index.php or .htaccess file. Here is how I’ve set mine up:


/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';

switch($_SERVER['HTTP_HOST']) {
  case '':
  case '':
  $mageRunCode = 'store1';
  $mageRunType = 'website';
  case '':
  case '':
  $mageRunCode = 'store2';
  $mageRunType = 'website';
Mage::run($mageRunCode, $mageRunType);

Additional Magento updates

Share pages when applicable

Visit each CMS page and/or static block from your install and update the store permissions as necessary. Be sure to notice the selection to apply to “All stores” (versus selecting both stores) as this will keep your pages available to a third website if you ever do add one.

Point design settings to a copy of local design files

Update the Design settings to point to this second website theme for overrides as needed.

Store2 Website:

  • Config > General > Web > Base URL update (http://magentostore2.local/)
  • Default Pages: store2_home
  • Config > General > Design > change “store1” to “store2”


Header: images/store2.png

http://magentostore2.local/ (or similar) should now load an basic page similar to that of Store1.

Use store variables

If you find that your pages are very similar aside from the occasional store name sprinkled in, you can update your page to use a site variable (e.g. reference the Store name variable) instead of using text. This allows a page to display the name of the store it is referenced from so you only have to maintain one page for two websites.

Other considerations


If you are already using an SSL certificate, simply copy this code into a new sites-available similar to how you added the second website previously. However the code for the SSL should be within the <:443> module.

Restricting your second website for testing

In order to restrict viewing of your second website to your IP only, use the <Location /> within the sites-available. (The developer IPs in the Magento admin settings are NOT for restricting access!) Here is an example of my full sites-enabled code including the <Location /> tag. When you are ready for the world to see your second website, remove the entire <Location /> block. Restart your server after testing and making changes.


<Location />
Order deny,allow
Deny from all
Allow from 174.45.x.x


Although I did a lot of development testing using MAGMI, I ended up recreating the products from scratch on my second website. The easiest way to do this is to create your configurable product and then create the Associated Products using the Quick-Create. You can then go back and fill in all product information on the parent product as necessary.

To transfer customers, I was able to use the built-in Import and Export functions for Magento. For orders and sales, I found Aitoc Orders Export and Import to be extremely efficient. Since you are adding sales and orders into an existing system, be sure to update the order IDs to start with 20000 instead of 10000 using find replace on any exported CSV files. After you’ve finished, you must update your indexes so they are ready for new orders.

Additional Resources:

Speeding Up Load Times on Magento CE 1.9x

While this entry could also be aptly named OMG How Do I Make Pages Load Faster in Magento?, I’ve finally found a solution to speeding up my Magento website that makes me so much less bitter, I can now even think semi-straight. If you’re searching for answers as well–and perhaps not finding adequate solutions–I hope this post will be of value for learning all the different ways to increase your Magento website’s performance!

First, let’s go over the items I did try and what worked. Many of the first items deal with configuring your server install, so be prepared!

If you haven’t yet become versed in Linux and are joining the ranks of well-rounded web developers, check out “How Linux Works,” a guide that covers every useful feature you need to know–gain confidence in the command line!

The Run Around

Here is a list of all the items I tried. Some may be useful, but many seemed to not even make a dent in site performance.

  • Grab a Page Load Extension–Want to know if your page is loading any faster? Check out Page load time on Chrome and see how long your page takes each time you load it! The goal is to see those numbers dwindle.
  • Optimize your images–Photoshop has the ability to optimize your images for the web. Try it out and save some bandwidth. There are also online tools for optimizing your images such as Large images do make a big impact on your page load time and may strain your server.
  • Merge ALL the things–Can you combine it any further? Can you remove any unused CSS? Yes, you probably can work on cleanup for hours and it still only saves 50kB. Congrats! Your load speed is still the same. (Although, if you’re wondering, merge your JS and CSS files using: System > Configuration > Advanced > Developer)
  • Compress ALL the things–If you do a search on “gzip” or “deflate” for Magento, you will find all sorts of walkthroughs. After hours of playing with your Apache modules and .htaccess files, you’ll be an expert in server settings. (However your site will probably be only nanoseconds faster.)
  • Cache ALL the things?Okay, so this is getting ridiculous now. Go enable some more modules and check the expiry on your images and files. All good to go? Great job.
  • Research more–Check your server memory. Read about Varnish. Research Magento optimization companies and start crying when you realize their own sites don’t load under three seconds either.

At this point, if you are still here, you may be wondering if I actually found some solution to my slow Magento site.

My Answer: Full Page Cache

Did you hear the musical echoes of the clouds parting?

This plugin from Magento Connect places magical kittens on your site to remember the queries your users make and keep the results for next time. It installed perfectly for me, and within 15 minutes, my pages were loading under three seconds (down from the 7-9 seconds from before.) On subsequent pageloads, some pages are even loading as fast as .92 seconds. I am by far stunned by this extension–for $149.00 it is worth your time, sanity and development–as well as customer retention–to make this investment in your site. I’m sure you won’t regret it.

I hope to come back in the next few months and share the rise in customer traffic that results from these lower pageload times! Until then, just know that I will be dancing around my website, zipping from page to page, all thanks to Magento’s Full Page Cache.

Are you struggling with your own Magento Community Edition 1x installation? Do you need updates to your plugins or new features added? Contact me and let’s chat about your website goals!

Have you found another method that worked for speeding up your Magento install? Please share!