Preconditions
Magento already created a default website on installation (in your case mystore1.com).
Step 1 - Creation
Go to System->Manage Stores
. Click on Create Website. Fill in the the form with desired values and save. Example:
- Name - Website 2
- Code - site2
- Sort Order: 2
Click on Create Store. In the form fill in the values and save. Example:
- Website - Website 2 (the one you created previously)
- Store for website 2
- Root Category - Default Category (same as the store in mystore1.com)
Click on Create Store View. In the form fill in the values and save. Example:
- Store
- Name - store for website 2 (the one you created above)
- Code - store2
- Status - Enabled
- Sort Order - 1
So far you have created a new website.
Step 2 - Configuration
Go to System->Configuration->Web->Unsecure
. From the top left dropdown select 'Website 2' (the website not the store view) and fill the following value.
- Base URL : http://www.mysite2.com/
- Base Link URL: {{unsecure_base_url}}
- Base Skin URL: {{unsecure_base_url}}skin/
- Base Media URL: {{unsecure_base_url}}media/
- Base JavaScript URL: {{unsecure_base_url}}js/
If some of them are already like that, leave them that way.
If you plan to use SSL on your website you should do the same on the Secure
section but fill in the secure url of your website for 'Base URL'.
- Base URL : https://www.mysite2.com/
- Base Link URL: {{secure_base_url}}
- Base Skin URL: {{secure_base_url}}skin/
- Base Media URL: {{secure_base_url}}media/
- Base JavaScript URL: {{secure_base_url}}js/
Save the changes and clear the cache.
Step 3 - Server configuration
Now you have to make the document root of mysite2.com point to the same folder as mysite1.com.
Add this to your httpd.conf
file
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /document/root/here
ServerName mysite2.com
</VirtualHost>
Now when you visit mysite2.com you will see the same homepage as mysite1.com but the first click you make will take you to mysite1.com.
To fix this add the following to .htaccess
.
SetEnvIf Host www\.mysite1\.com MAGE_RUN_CODE=base #or the code for mysite1.com
SetEnvIf Host www\.mysite1\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^mysite1\.com MAGE_RUN_CODE=base #or the code for mysite1.com
SetEnvIf Host ^mysite1\.com MAGE_RUN_TYPE=website
SetEnvIf Host www\.mysite2\.com MAGE_RUN_CODE=site2 #or the code for mysite1.com
SetEnvIf Host www\.mysite2\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^mysite2\.com MAGE_RUN_CODE=site2 #or the code for mysite1.com
SetEnvIf Host ^mysite2\.com MAGE_RUN_TYPE=website
Restart the server, clear the cache again just in case (contents of var/cache) and you should be ready.
In case I missed something you can check this tutorial that basically says the same things.
[EDIT]
After configuring the new website, in order to separate the customers go to System->Configuration->Customer Configuration->Account Sharing Options
and set the value for Share Customer Accounts to Per website.