I was getting crazy trying to solve this. Finally I found the solution.
After create the X Websites you need from your Admin section we have to edit a piece of code.
Note: each Website has one unique Store and one unique Store View.
Note2: use short and easy Websites codes, we will need them now.
![store1_code](http://php.quicoto.com/wp-content/uploads/2010/03/store1_code.jpg)
Sub Domain Method
In your Index.php file (in the root directory of the Magento installation) you have to look for:
$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);
Then replace the found code for this new one:
// this first line detects the domain / sub domain
switch($_SERVER[‘HTTP_HOST’]) {
case ‘store1.domain.com’:
/* store1 is the code you wrote in the admin
when created the website */
Mage::run(‘store1’, ‘website’);
break;
// domain.com (default store)
default:
Mage::run();
break;
}
Sub Directory Method
Using a Sub Directory means more job.
First of all you need to create as much as directories you wanna have.
Example:
http://mydomain.com/store1
http://mydomain.com/store2
So following the example you will create 2 directories in the root of your magento installation.
Now you have to copy & paste the index.php and the .htaccess to those folders.
Once that we need to edit the index.php.
Look for:
$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 replace it for:
// this will force to load the Website with the code store1
Mage::run(‘store1’, ‘website’);
You need to repeat this step to every folder, to every index.php you created before.
Now check out this screenshot to see how to configure the Website:
Done!
Now you know how to create multiples Websites in one Magento Installation.
![system-config-website](http://php.quicoto.com/wp-content/uploads/2010/03/system-config-website1-300x231.jpg)
After create the X Websites you need from your Admin section we have to edit a piece of code.
Note: each Website has one unique Store and one unique Store View.
Note2: use short and easy Websites codes, we will need them now.
![store1_code](http://php.quicoto.com/wp-content/uploads/2010/03/store1_code.jpg)
Sub Domain Method
In your Index.php file (in the root directory of the Magento installation) you have to look for:
$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);
Then replace the found code for this new one:
// this first line detects the domain / sub domain
switch($_SERVER[‘HTTP_HOST’]) {
case ‘store1.domain.com’:
/* store1 is the code you wrote in the admin
when created the website */
Mage::run(‘store1’, ‘website’);
break;
// domain.com (default store)
default:
Mage::run();
break;
}
Sub Directory Method
Using a Sub Directory means more job.
First of all you need to create as much as directories you wanna have.
Example:
http://mydomain.com/store1
http://mydomain.com/store2
So following the example you will create 2 directories in the root of your magento installation.
Now you have to copy & paste the index.php and the .htaccess to those folders.
Once that we need to edit the index.php.
Look for:
$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 replace it for:
// this will force to load the Website with the code store1
Mage::run(‘store1’, ‘website’);
You need to repeat this step to every folder, to every index.php you created before.
Now check out this screenshot to see how to configure the Website:
Done!
Now you know how to create multiples Websites in one Magento Installation.
![system-config-website](http://php.quicoto.com/wp-content/uploads/2010/03/system-config-website1-300x231.jpg)
(Visited 50 times, 1 visits today)