Configuring Multiple Magento Stores on a Single Installation
In today’s e-commerce landscape, it’s not uncommon for businesses to run multiple online stores from a single Magento installation. This approach allows you to manage your products, customers, and inventory centrally while maintaining separate branding and domain names for each store.
I recently encountered this scenario with a client who wanted to set up two separate domains for their laptop sales business: www.laptops.com and www.cheaplaptops.co.uk. Let’s dive into the step-by-step process of configuring these multiple stores within a single Magento installation.
Setting Up Your First Store
To begin, you’ve already installed Magento on your primary domain, www.laptops.com, with the following configurations:
- Magento Website Name: “laptops.co.uk”
- Magento Website Code: “laptops”
This is the default installation, and everything should be working perfectly.
Creating an Add-on Domain for Your Second Store
For your second store at www.cheaplaptops.co.uk, you’ve created a new add-on domain within your hosting account’s cPanel interface. This process involves adding the new domain and pointing it to a specific folder on your server, typically located in the public_html directory.
Here are the steps involved:
- Log in to your cPanel.
- Navigate to the “Domains” section and click on “Add-on Domains”.
- Enter the details for your new domain (e.g., www.cheaplaptops.co.uk) and select a folder where you want to store the files.
- Click on “Add Domain” to create the add-on domain.
Configuring Your Magento Installation for Multiple Stores
Once the add-on domain is set up, it’s time to configure your existing Magento installation to work with both domains.
Step 1: Create a New Website and Store View in Magento Admin
Log in to your Magento admin panel (usually accessed via www.laptops.com/admin) and navigate to “System” > “Manage Stores”.
Click on the “Add Your Store” button located at the top right corner of the page.
Enter the following details for your new store:
- Website Name: “cheaplaptops.co.uk”
- Store Name: “Cheap Laptops UK”
- Store Code: “cheaplaptops”
Click on the “Save Store” button to create the new website and store view.
Step 2: Update Your Add-on Domain’s htaccess and index.php Files
To make your add-on domain work with the newly created Magento store, you need to update the htaccess and index.php files located in your add-on domain’s folder (public_html/cheaplaptops).
Updating the htaccess File
Open the htacess file in a text editor. You should see something like this:
# DO NOT REMOVE THIS LINE ON PASSWORDS ENCODING PROBLEM
RewriteEngine on
RewriteBase /public_html/cheaplaptops/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /public_html/cheaplaptops/index.php [L]
Replace the RewriteBase line with:
RewriteBase /public_html/cheaplaptops/
Updating the index.php File
Open the index.php file in a text editor. You should see something like this:
<?php
define('MAGENTO_ROOT', getcwd());
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Replace the entire contents with the following code:
<?php
if (file_exists('../public_html/app/Mage.php')) {
require_once '../public_html/app/Mage.php';
} else {
die('Invalid Magento Root.');
}
define('MAGENTO_ROOT', getcwd());
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Step 3: Configure Your Add-on Domain’s Base URL
Back in your Magento admin panel, navigate to “System” > “Configuration”.
Under the “General” tab, scroll down to the “Web” section and click on the link under “Default Configurations for Store View”.
Select your new store view (“Cheap Laptops UK”) from the dropdown menu.
Scroll down to the “Secure” tab and update the following fields:
- Unsecure Base URL:
http://www.cheaplaptops.co.uk/ - Secure Base URL:
https://www.cheaplaptops.co.uk/
Click on the “Save Config” button at the top right corner of the page.
Step 4: Clear Magento Cache
To ensure that your changes take effect, you need to clear the Magento cache. Navigate to “System” > “Cache Management”.
Select all the caches and click on the “Flush Magento Cache” button located at the top left corner of the page.
Conclusion
Configuring multiple Magento stores from a single installation requires careful attention to detail and a solid understanding of Magento’s file structure and setup process. By following the steps outlined above, you can successfully create separate domains for each store while managing them centrally within your Magento admin panel.
Remember that proper domain management is crucial for maintaining the integrity of your online business. Ensure that you have configured your DNS settings correctly and that your add-on domains point to the appropriate folders on your server.
If you’re still having trouble or need further assistance with configuring multiple Magento stores, don’t hesitate to reach out to our team of experienced Magento developers at Laravel Company. We’d be more than happy to help you optimize your e-commerce setup for maximum performance and customer satisfaction.