2/15/2011

How to configure multiple websites with multiple domain in a single magento

This is One of Magento's best and popular features of magento which allows to run Multiple website with multiple domain name in a single magento.To conigure multiple website or multiple domain Follow the below process.

Create 2 or more website, Store and storeview from System-> Manage Stores

See the below screenshot

Now go to System->Configuration->Web
From Current Configuration Scope: Select your first website i.e website1. Then from Unsecure tab change your Base URL from {{base_url}} to your domain name (e.g http://www.n2ndevelopers.com/)
Do the same for Website2 and website3 by selecting website2 and website3 From Current Configuration Scope:
Below 3 screenshot shows how to do this








Now open your magento Index.php file which you will found in your magento rrot folder. open it and comment the below code

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);

And paste the below code

switch($_SERVER['HTTP_HOST']) {
case 'website1.com':
Mage::run('website1', 'website');
/* website1 is the code you wrote in the admin when created the website */
break;
case 'website2.com':
Mage::run('website2', 'website');
break;
case 'website3.com':
Mage::run('website3', 'website');
break;
default:
Mage::run();
break;
}

and Enjoy

1 comment:

  1. Thats really cool man, thanks for posting.
    keep up the good work dude....

    ReplyDelete