In this post, we will guide you how to setup multiple websites in Magento
As you know, Magento support multiple websites stores and store views. That means you can manage separate websites using same admin panel. Each website has its own settings, themes, products, customers …
In this post, we will tell you how to create and setup multiple website on Magento 1.
Step 1: Create a website in Magento admin
Go to System -> Manage Stores -> Create Website
Please remember new website code, store code because you will need it when editing index.php file.
Step 2: Create a new Root Category
( optional – if your new website has different products )
Go to Catalog -> Manage Categories -> Add Root Category
Step 3: Create a new Store
Go to System -> Manage Stores -> Create Store, select the website and the root category that you’ve just created.
Step 4: Create a new Store View
Go to System -> Manage Stores -> Create Store View, select the store that you’ve just created.
Step 5: Set new website Base URL
Go to System -> Configuration -> General -> Web -> Change “Current Configuration Scope” to the new website.
Edit Base URL in “Unsecure” & “Secure” tab using your new website domain.
Step 6: Edit index.php file in Magento root directory
Use your Cpanel File Manager or other FTP Clients as FilleZilla, WinSCP. Move to document root of Magento installation, then edit index.php file. You should create a backup of this file before editing.
Add this code:
1 2 3 4 |
if ($_SERVER['HTTP_HOST'] == "yournewdomain.com" || $_SERVER['HTTP_HOST'] == "www.yournewdomain.com"){ $_SERVER["MAGE_RUN_CODE"] = "the_second"; // this is the website code $_SERVER["MAGE_RUN_TYPE"] = "website"; } |
BEFORE:
1 2 3 4 5 |
/* 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'] : 'store'; |
Step 7: Flush Magento Storage Cache in System -> Cache Management.
It’s done, that’s how to setup multiple websites in Magento 1.
In the next tutorial, we will guide you to do this in Magento 2.
If you have any question, please leave a comment.