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:
I have Apache configured in
/etc/httpd/conf/httpd.conf with the following document roots:
What should I put in the second domain directory (.htaccess, index.php? should I copy it from first one?)
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.
You should copy
.htaccess files on your second domain directory.
Open up the
index.php file and look for this line (it's the last line of the file):
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
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
Step 4: Clear cache and access your domains.
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
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.
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
Overview, Problems & Confusions: https://www.cloudways.com/blog/magento-multi-store-importance-and-some-common-issues/