Magento 1.9 multiple websites on different domains

by sellio   Last Updated February 11, 2019 09:09 AM

I read and viewed all things related to multiple websites for Magento, but I still cannot setup properly to handle different domains with different Magento websites.

Could somebody let me know step by step, how to setup the virtual hosts properly and htaccess or/and index.php?

I know that setting multiple websites in subdomains/catalogs is easy, but I like it to work with different domains.

I have set up everything in Magento admin:

1st store:

  • domain: abc.com
  • website code: domain1

2nd store:

  • domain: xyz.com
  • website code: domain2

I have Apache configured in /etc/httpd/conf/httpd.conf with the following document roots:

  • /home/admin/domains/abc.com/public_html
  • /home/admin/domains/xyz.com/public_html

What should I put in the second domain directory (.htaccess, index.php? should I copy it from first one?)



Answers 5


You can find how to setup multiple storefronts on one Magento installation by following: http://www.ecommercegorilla.com/how-to-set-up-multiple-store-fronts-with-magento/

This method works for any store post Magento CE 1.4

Look to the end of the article you will see there are two methods, one that uses separate directories for each domain and a second method that allows you to use pointer domains.

If you are looking to have customers checkout on the store domain and not one shared domain under SSL you will want to use the separate directories method. It describes how to setup the symbolic links so the store will properly pull files and how to modify the the index.php of each store to assign the correct website/store code.

Eirik
Eirik
August 15, 2014 22:18 PM

You should copy index.php and .htaccess files on your second domain directory.

After that:

Open up the index.php file and look for this line (it's the last line of the file):

Mage::run($mageRunCode, $mageRunType);

Add the following code right before the above code:

$mageRunCode = 'YOUR_WEBSITE_CODE';

$mageRunType = 'website';

Lastly, you need to create symbolic links to point to a few directories:

ln -s your_magento_root_directory/app ./app

ln -s your_magento_root_directory/errors ./errors

ln -s your_magento_root_directory/includes ./includes

ln -s your_magento_root_directory/js ./js

ln -s your_magento_root_directory/lib ./lib

ln -s your_magento_root_directory/media ./media

ln -s your_magento_root_directory/skin ./skin

ln -s your_magento_root_directory/var ./var

Source: http://www.crucialwebhost.com/kb/how-to-setup-multiple-magento-stores/

Mukesh Chapagain
Mukesh Chapagain
September 13, 2015 10:02 AM

You don't need to have multiple directories for multiple domains if you are using single magento instance to fulfill your requirements.

Step 1: Point all domains to Magento root directory, i.e. same document root in the webserver (Apache or Nginx) configuration.

Step 2: Configure domain names as base URLs for each website in System Configuration in Magento admin panel.

Step 3: Set store or website for each domain as environment variable in .htaccess or in the webserver configuration.

  • Example with the websites as given in the question:

    SetEnv MAGE_RUN_TYPE website
    SetEnvIf Host abc\.com MAGE_RUN_CODE=domain1
    SetEnvIf Host xyz\.com MAGE_RUN_CODE=domain2
    
  • Example with store views instead of websites

    SetEnv MAGE_RUN_TYPE store
    SetEnvIf Host abc\.com MAGE_RUN_CODE=store_code_1
    SetEnvIf Host xyz\.com MAGE_RUN_CODE=store_code_2
    

    These configurations check if the domain contains "abc.com" or "xyz.com", which I find useful to also match subdomains or test systems like abc.com.testserver.com or test.abc.com, using the same .htaccess file. If you want exact matching, replace abc\.com with ^abc\.com$

Step 4: Clear cache and access your domains.

Aman Srivastava
Aman Srivastava
June 21, 2016 06:03 AM

You can follow below steps to configure your multi store in magento:

1) All domains which you are adding as another domains like xyz.com, point this domain to your main magento website url abc.com
2) open your admin panel, and add website, Store and Store view in your Manage Store
3) open your .htaccess file and add below code

SetEnvIf Host .xyz.com. MAGE_RUN_CODE=domain2
SetEnvIf Host .xyz.com. MAGE_RUN_TYPE=website

4) Go to configurations > Web, change your store view and add your domain url's there.
5) Save and clear cache

This will configure multi website. Let me know if this will work for you.

Rahul
Rahul
June 21, 2016 06:19 AM

After configuring Magento MultiStore through the backend, you need to make few changes in your .htacces file

After creating the secondary Domain, add the following Code in your .htaccess file.

SetEnvIf Host www\.newstore\.com MAGE_RUN_CODE=domain1_com
SetEnvIf Host www\.newstore\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^newstore\.com MAGE_RUN_CODE=domain1_com
SetEnvIf Host ^newstore\.com MAGE_RUN_TYPE=website

For more details, you can refer to following links

Magento 1: https://www.cloudways.com/blog/how-to-setup-multiple-stores-on-magento/

Magento 2: https://www.cloudways.com/blog/create-and-configure-multistore-magento-2/

Overview, Problems & Confusions: https://www.cloudways.com/blog/magento-multi-store-importance-and-some-common-issues/

AbdurRahman Lakhani
AbdurRahman Lakhani
February 11, 2019 08:09 AM

Related Questions


Updated July 21, 2015 13:04 PM

Updated November 08, 2017 10:09 AM

Updated September 20, 2017 16:09 PM

Updated March 28, 2019 05:09 AM

Updated March 21, 2016 09:03 AM