One Magento Installation on Multiple Domains
Plesk is a terrific control panel for multiple reasons – it allows complete administration for all of your websites that are hosted there. This includes the setup of SSL certificates, local database access, SSH access, the ability to switch domains off at the flick of a switch and much more. By much more I’m talking about ‘Domain Aliases’.
It has become an increasing requirement for me to have multiple domains using the same Magento installation, and those multiple domains show different websites that are set up on that installation. I have domain1.co.uk which holds the Magento Installation, I also have domain2.co.uk which is a website on that Magento Installation. Okay so here’s how you do it…
1. Point DNS – Point the DNS A Record of domain2.co.uk to the IP address of domain1.co.uk.
2. Create Domain Alias – In Plesk, go to the domain overview area for your version of domain1.co.uk and click on ‘Domain Aliases’. Now click ‘Add Domain Alias’ and type in the name of the website (without the http://www part). So I type in domain2.co.uk.

3. Create Website in Magento - In the Magento Admin area go to System > Manage Stores. Click on ‘Create Website’ and enter the name of the domain into Name field. You also need to enter a code to identify the website (you’ll need this later) – I just went with domain_2. As this isn’t my4. primary domain, I put the sort order as 2. You should also create an associative store and store view for this new website in the same way. Read my earlier post about websites/stores/store views for more information.

4. Change the Base URL - Go to System > Configuration > Web. Change the configuration scope (top left) to the secondary website (domain2.co.uk). You now need to change the secure and unsecure Base URL to the new domain, without forgetting to put the forward slash at the end of both.

5. Update the .htaccess – Now that everything’s in place it’s simply a case of adding some code to the bottom of your main Magento .htaccess file so that Magento knows to load your new website when accessed from that domain. The code for my website domain2.co.uk would look like this:
SetEnvIf Host www\.domain2\.co.uk MAGE_RUN_CODE=domain_2 SetEnvIf Host www\.domain2\.co.uk MAGE_RUN_TYPE=website SetEnvIf Host ^domain2\.co.uk MAGE_RUN_CODE=domain_2 SetEnvIf Host ^domain2\.co.uk MAGE_RUN_TYPE=website
You can see at the end of line 1 & line 3 that the website code I defined earlier as ‘domain_2′ has been appended accordingly. Save your .htaccess file and upload (or just save it if you’re doing it through Plesk). Without sounding like the official advocate of all that is Plesk, it really is a good way of configuring the server settings of your Magento site and can save you a lot of time and energy.
Thanks for reading the Magento Blog at E-commerce Web Design, I’d love to know how you all get on with creating your additional Magento URLs so please leave a comment and let me know.

July 12th, 2010
Hey Adam, I’m from Parallels and we really appreciate your great article. Could you email me (zcohn@parallels.com) and tell me a bit more about your experience with Parallels?
July 14th, 2010
Hi,
I have a doubt .For the second domain i copied my main sites .htacess and index.php in a subfolder like
main.com/sub.Then the main.com/sub works like a charm in server.But the issue is that i have to run the main.com/sub with domain name main2.com only.
How can i make that possible.
Waiting for a reply
Thanks
Princy
July 14th, 2010
When you created the main.com/sub folder – did you create this as a website, or a store? You need to make sure that it is a website, you don’t need to have the subfolder anymore. If you follow my instructions on Plesk it will work.
If you had created a store beforehand, create a new website which uses that store – and use that website code in the main.com .htaccess.
July 15th, 2010
Hi,
Thanks for your reply.I already have a diffrent website running with different skin and even diff. customers .
Bcs i was running that like mage::run(’sub’,'website’).And was wrking well.
My hosting provider is not providing me two domains in same account or even the IP pointing as you told.
That is my issue .I did the things same as your documentation .Now i skipped the subfolder and following your docs.They are telling me like we should do this using magento http_host,
Can you help me how can i do that way
Thank you very much
Princy Joy
July 15th, 2010
is it possible to use more than one domains hosted on different server.
say, domain1.com where actual magento is installed
now another domain domain2.com hosted on different server.
what i want is, I want to run a site shop.domain2.com using same magento installed in domain1.com. how can i do that?
July 15th, 2010
Tuba, you just need to point the DNS of domain2 to domain 1’s IP address and set up the domain alias. They can be registered on different servers, but they most be hosted on the same server for this method to work.