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.
URL Structure
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:
Code: Select all
mall.com/shoes
mall.com/shirts
Code: Select all
shoes.com
shirts.com
Code: Select all
mall.com
shoes.mall.com
shirts.mall.com
Shared Hosting Caveat
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:
All of your stores do not have a secure checkout, which is fine if you're using PayPal, Google Checkout, or a similar third-party service that handles the processing of card data on their website. For example, visitors to any of your stores are redirected to a third-party website for card processing.
All of your stores are setup as subdomains, and you've purchased a wildcard SSL certificate, which is roughly $1000/year and is for legally registered businesses.
If you do need an SSL certificate for all of your domains, you will need to be in a dedicated hosting environment. In this type of environment, all domains will be able to access the same set of files.
Adding Another Store In Magento
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.
Login to the Magento admin.
Go to the Catalog tab, and select Manage Categories.
Click on the Add Root Category button on the left.
On the right, for the Name, we'll enter Shoes.com. Set the dropdown to Yes for both Is Active and Is Anchor.
Click the Save Category button.
Go to the System tab and select Manage Stores.
Click on the Create Website button.
For the Name, we'll enter Shoes.com, and for the Code, we'll enter shoes. We'll use this value later, so don't forget this!
Click the Save Website button.
Click on the Create Store button.
For the Website, select Shoes.com from the dropdown. For the Name, we'll enter Main Store. For the Root Category, select the Shoes.com from the dropdown.
Click on the Save Store button.
Click on the Create Store View button.
For the Store, select Main Store from the dropdown, making sure it's for the Shoes.com website. For the Name, we'll enter English. For the Code, we'll enter shoes_en. For the Status, select Enabled from the dropdown.
Click the Save Store View button.
Go to the System tab and select Configuration.
For the Current Configuration Scope (located on the top left), change the dropdown menu from Default Config to Shoes.com.
Select Web from the sidebar on the left under the General heading.
For both the Unsecure and Secure sections, uncheck the Use default box next to the Base URL item, and enter the URL for your store, e.g. http://www.shoes.com/. Don't forget the trailing slash!
Click the Save Config button.
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.
Parked Domain 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:
Login to cPanel for your domain and click on the Parked Domains icon.
In the input field, enter the domain name that you'll be setting up as a second store, e.g. shoes.com.
Click on the Add Domain button.
Open up the index.php file for Magento and look for this line (it's the last line of the file):
Code: Select all
Mage::run($mageRunCode, $mageRunType);
Code: Select all
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:
Login to cPanel for your domain, and click on the Addon Domains icon.
For the New Domain Name, we'll enter shoes.com. cPanel will automatically fill in the next two fields, so remove public_html/ from the Document Root field, leaving us with just shoes.com. This step isn't required, but for organizational purposes, it makes more sense.
Set a password for this domain and click on the Add Domain button.
Login to your site via SSH, and go to the directory that we previously set in the Document Root field above when adding our domain. In our case, we would do the following:
Code: Select all
cd shoes.com/
Code: Select all
cp ../public_html/index.php ../public_html/.htaccess .
Code: Select all
$mageFilename = 'app/Mage.php';
Code: Select all
$mageFilename = '../public_html/app/Mage.php';
Code: Select all
Mage::run($mageRunCode, $mageRunType);
Code: Select all
$mageRunCode = 'shoes';
$mageRunType = 'website';
Code: Select all
ln -s ../public_html/app ./app
ln -s ../public_html/errors ./errors
ln -s ../public_html/includes ./includes
ln -s ../public_html/js ./js
ln -s ../public_html/lib ./lib
ln -s ../public_html/media ./media
ln -s ../public_html/skin ./skin
ln -s ../public_html/var ./var
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.
There are some other ways to add stores, But I only tried above 2.