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 webmaster@mysite2.com
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.
This is a common issue in Magento. You can view that the url "http://thehubcollection.com/index.php/ethinic.html" is showing the result fine, it is due to insertion of index.php in the url.
To avoid this and make it work the other way, you will need to enable the mode_rewrite_url(Configuration>Web>Search Engine optimization), and if it is already yes, then
- Disable it(If it is fine for you to keep the site running with index.php, then ignore the other two steps)
- Get the mod_rewrite enabled from server side
- Enable the mod_rewrite from admin area, and clear cache.
Best Answer
First you need to find a way to identify "preferred" website of the customer. The one you need to redirect to.
You can do that by adding a dropdown customer attribute that has options the websites, or use the customer attribute
website_id
.Let's use the
website_id
attribute for now.You need an observer on the event
controller_action_predispatch
for frontend. This is dispatched for every page.Your observer method should look something like this:
Now all you need to do is to allow the customers to keep the session between sites.
You can do that from
System->Configuration->Web->Session Validation Settings
. Set the fieldUse SID on Frontend
toYes
.Save and clear the cache just in case.