July 6, 2021 . 9 MIN READ
There are numerous ways to setup multiple Magento stores that all share the same codebase and backend, but what method you use depends on your needs.
This article is written with cPanel in mind, though the methodologies listed below apply no matter what control panel you’re using. You will need Magento 1.4.x or greater installed too.
The actual URL structure of your stores is a matter of personal preference. You can, for example, have two entirely different stores running on the same domain that share the same instance of Magento:
These stores could also be setup on their own domain and still share the same instance of Magento:
Another example would be a mall type setup, where your primary domain is the portal to access various stores:
Regardless of the URL structure, the method for setting this up will pretty much be the same, and the result is what we’re really after, which is to have one codebase for all of your stores, and one backend to manage all of these stores from.
If you want each store to have it’s own SSL certificate and don’t want to share a single checkout, e.g. you don’t want visitors leaving domainA.com to checkout on domainB.com, then you will not be able to do this in a shared hosting environment.
The reason why you cannot do this is simple. In order for a website to have an SSL certificate, it requires a dedicated IP address.
There’s no way to allow an addon or parked domain in cPanel to have its own IP address. Instead, it shares the IP address of the primary domain.
You probably think you could sign up for two shared hosting accounts, so each one has its own dedicated IP address, but that won’t work either.
Since it’s shared hosting, there are security measures in place to prevent one user from reading the files of another user.
So for shared hosting clients, you’re limited to the following scenarios:
If you do need an SSL certificate for all of your domains, you will need to be in a dedicated hosting environment, such as our Split-Dedicated platform. In this type of environment, we can install a multi-domain or UCC certificate.
The first thing we need to do is setup our second store in Magento.
We’re going to do a hypothetical here for the naming conventions, and assume we own shirts.com. Adjust the values accordingly for your own store.
Now that we have our second store setup, you’ll need to choose one of the following methods for actually setting up the store on the server-side so visitors can access it.
If the URL structure you’ve chosen will have different domains for each store, the parked domain method is the fastest and easiest method.
For this method, we’ll pretend we own shirts.com and shoes.com. The shirts.com domain is our primary domain, and Magento is already installed on it. Here’s how we would set this up for the shoes.com domain:
Mage::run($mageRunCode, $mageRunType);
…and right before this, we’re going to add the following code:
switch($_SERVER[‘HTTP_HOST’]) { case ‘shoes.com’: case ‘www.shoes.com’: $mageRunCode = ‘shoes’; $mageRunType = ‘website’; break;}
If you have more than two stores, you will need to add additional cases to the above code block, e.g.:
switch($_SERVER[‘HTTP_HOST’]) { case ‘shoes.com’: case ‘www.shoes.com’: $mageRunCode = ‘shoes’; $mageRunType = ‘website’; break; case ‘hats.com’: case ‘www.hats.com’: $mageRunCode = ‘hats’; $mageRunType = ‘website’; break;}
This is the same scenario as above, except it takes a little longer to setup. This method might be more useful to you if, for example, you wanted to have a blog on one domain, but not on the other. You couldn’t do that with a parked domain. Here’s how we would set this up for the shoes.com domain:
cd shoes.com/
cp ../public_html/index.php ../public_html/.htaccess .
Mage::run($mageRunCode, $mageRunType);
…and right before this, we’re going to add the following code:
$mageRunCode = ‘shoes’;$mageRunType = ‘website’;
8. ln -s ../public_html/app ./app9. ln -s ../public_html/errors ./errors10.ln -s ../public_html/includes ./includes11.ln -s ../public_html/js ./js12.ln -s ../public_html/lib ./lib13.ln -s ../public_html/media ./media14.ln -s ../public_html/skin ./skinln -s ../public_html/var ./var
For this method, we’ll pretend we own mall.com, and it’s setup as a portal that links to the various shops within the mall. Magento will be installed on the mall.com domain, and all of the shops will be in sub domains, e.g.:
Here’s how we would set this up for the shoes sub domain:
cd shoes/
cp ../public_html/index.php ../public_html/.htaccess .
Mage::run($mageRunCode, $mageRunType);
…and right before this, we’re going to add the following code:
$mageRunCode = ‘shoes’;$mageRunType = ‘website’;
8. ln -s ../public_html/app ./app9. ln -s ../public_html/errors ./errors10.ln -s ../public_html/includes ./includes11.ln -s ../public_html/js ./js12.ln -s ../public_html/lib ./lib13.ln -s ../public_html/media ./media14.ln -s ../public_html/skin ./skinln -s ../public_html/var ./var
This is the same scenario as above, except all of the shops will be in subdirectories, e.g.:
Here’s how we would set this up for the shoes subdirectory:
2. cd public_html3. mkdir shoes/cd shoes/
cp ../public_html/index.php ../public_html/.htaccess .
Mage::run($mageRunCode, $mageRunType);
…and right before this, we’re going to add the following code:
$mageRunCode = ‘shoes’;$mageRunType = ‘website’;
It’s very important to remember that now that you have multiple stores to manage from one admin panel, that you make sure you’re changing the configuration for the appropriate store.
In the System → Configuration section, if you leave the dropdown menu for Current Configuration Scope set to Default Config, it will globally change the values for all of your stores, assuming you haven’t removed the checkmark next to Use default throughout the configuration sections.
You can change the configuration values globally, for each website, and for individual store views.
For those of you in dedicated hosting environments, you can follow either the addon or parked domain method from above, and edit the httpd.conf file to give the addon or parked domain a dedicated IP address. However, this is not advised. Your changes will most likely be overwritten with a control panel upgrade, Apache or PHP rebuild, or even simple maintenance.
Your best bet would be to purchase a Unified Communications Certificate (UCC), also known as a multi-domain or multiple domain certificate. If you’re on our Split-Dedicated product, after you’ve purchased and installed this certificate, we can make the necessary changes to support this type of certificate (this is something we have to do, since it’s not natively supported by cPanel). Once we have the SSL setup, you simply follow the parked domain method for each domain you’ve assigned to your UCC certificate.
This is just one of the many advantages of running your online business in a more secure and flexible hosting environment like this.
Once you’ve done the above, all of your stores will have their own secure checkout and will still share the same codebase and backend for management purposes.