Home
/
Other Applications
/
How to configure your Magento 1.x application to work as a Multistore?

How to configure your Magento 1.x application to work as a Multistore?

The primary use of the Magento multistore functionality is to create multiple stores accessible on different URLs under the same Magento installation. All stores under the Magento multistore installation share the same backend, which makes the administration easier.

The first step to setup Magento multistore is to install Magento. You could do that by either installing the application through App Manager or by installing Magento manually.

Once you have installed Magento, you could start building your multistore. To do that, log in the backend of your Magento installation.

Once there, follow the steps below to add a new store:

  • Go to CatalogManage Categories;
  • Click on the Add Root Category button;
  • Enter the name of your store. In this tutorial, we will use sgtest.com.
  • Select Yes from the drop-down menu of the Is Active setting;
  • Click on the Display Settings tab and select Yes from the drop-down menu of the Is Anchor setting.
  • Save the category.

Once the category is saved, you could create a new store. You could do so by:

  • Go to SystemManage Stores.
  • Click on the Create Website button.
  • For Name, we will use sgtest.com and for Code – sgtest.
  • Save the website.
  • Click on Create Store.
  • Select sgtest.com for Website and Root Category. For Name, we will use Main Store.
  • Save the store and click on Create Store View.
  • Select the newly created store ( sgtest.com ) from the drop-down menu. For the Name and Code, we will use sgtest. Select Enabled for Status and save the store view.

The last steps to complete the store creation is to configure its settings through the configuration of your Magento. Follow the steps outlined below:

  • Go to SystemConfiguration;
  • Select the newly created store from the Current Configuration Scope drop-down menu on the left side;
  • Go to the Web tab, uncheck the Use Default box next to Base URL and change both the Secure and the Unsecure URLs to your domain, in this case, http://sgtest.com/. Make sure to add the trailing slash at the end of the URL.
  • Save the configuration.

After the store is created through the backend of Magento, you should choose how the new domain will be used. There are several possible setups and we will explain each one of them below.

Parked Domain Method:

To use that method, first, you need to add your domain as a parked domain through your Site Tools.

Once the domain is added, open the index.php file of your Magento and find the line with the following code:

Mage::run($mageRunCode, $mageRunType);

This should be the last line in the index.php file. Right before that line, add the following block:

switch($_SERVER['HTTP_HOST']) {
case 'sgtest.com':
case 'www.sgtest.com':
$mageRunCode = 'sgtest';
$mageRunType = 'website';
break;
}

If you want to use more than one domain, you should add a new block for every domain. For example:

switch($_SERVER['HTTP_HOST']) {
case ‘sgtest.com’:
case ‘www.sgtest.com’:
$mageRunCode = ‘sgtest’;
$mageRunType = ‘website’;
break;
 
case 'mythirdstore.com':
case 'www.mythirdstore.com':
$mageRunCode = 'thirdstore';
$mageRunType = 'website';
break;
}

Save the index.php file, clear the cache of your Magento and you should be able to access the newly created store with its domain name.

Subdomain Method:

To use the Subdomain method, you need to add your subdomain through your Site Tools. This will create a separate document root directory for that subdomain. Once the domain is added, you need to establish an SSH connection to your account. Once connected, go to the directory for the corresponding subdomain. In this case, this will sub.sgtest.com.

Copy the index.php and the .htaccess files of your Magento installation to that directory:

Share This Article