Magento Multiple Store or Website Setup with Index.php

Wednesday, 14. September 2011

There are many ways to set up a multi-store or multi-website environment in Magento and make sure specific URL requests reaches the right website or store on Magento.

One popular way is to use the index.php file. Here are steps to do to get redirect URLs to associated stores or websites using this file.

Redirect URL to Magento’s website Code

1) Open index.php file

2) Search for the line below

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

3) Change it to

switch($_SERVER['HTTP_HOST']) {
	case 'domain.com':
	case 'www.domain.com':
		$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '<your_websitecode>';		
	break;
	default:
                $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
	break;	
}

4) Search for the line below

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Make sure the type is says website and not store:

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';

Redirect URL to Magento’s Store Code

Repeat the same steps as above but make sure this time around you specify store codes in place of website code. Also, on step 4, set the type to store as opposed to website

Leave a Reply

You must be logged in to post a comment.