I used to do it like this:
create the folders website1/store1
, website1/store2
, ...
Then, in the folder website1
clone the index.php and .htaccess
from the rood folder and replace this in index.php
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
with
$mageFilename = '../app/Mage.php';
and replace
/* 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';
Mage::run($mageRunCode, $mageRunType);
with
Mage::run('website1_code_goes_here', 'website');
Do the same for the folder website2 but change the code accordingly on the last line I mentioned.
Then copy the same files in the folder website1/store1
and change
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
with
$mageFilename = '../../app/Mage.php';
and
/* 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';
Mage::run($mageRunCode, $mageRunType);
with
Mage::run('store1_id_goes_here', 'store');
Do the same for the other store folders (website1/store2
, website2/store1
, website2/store2
) adjusting the last line accordingly.
Then you will have to go to System->configuration->web->unsecure
in the backend, select from the top left selector, website1
and fill in the base url field to http://www.domain.com/website1/
. Do the same for base link url.
and for media base url fill in http://www.domain.com/media/
. The same goes for skin and js urls.
Do the same for website 2.
Then select from the top left selector the store view store1
.
Fill in the base url to http://www.domain.com/website1/store1/
and the same for base link url. I don't think there is a need to change the values for base media/skin/js url.
Do the same for the 3 others store views.
Clear the cache and give it a go.