2

I have two stores within a single installation of Magento 1.9, both stores have their own domain name (domain1.com and domain2.com). The problem is that the second store isn't working when the user visits through the second domain (domain2.com). Initially, the homepage will work, but after clicking on a random link, the design from domain1.com is loaded. Then all the href attributes in the source code are from the first domain.

I figured out the following:

  • If I set the second store as a default (in Manage Stores), the second store is working, but then the first one is not.
  • Only the homepage of the second store is working.
  • The second store loads the design from the first store after clicking on a link.
  • If I change Add Store code to Urls to Yes, everything works fine, but I think this isn't the solution (for SEO reasons for example).

I added the following lines to the .htaccess file in Magento:

SetEnvIf Host www\.domain1\.com MAGE_RUN_CODE=website1
SetEnvIf Host www\.domain1\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain1\.com MAGE_RUN_CODE=website1
SetEnvIf Host ^domain1\.com MAGE_RUN_TYPE=website

SetEnvIf Host www\.domain2\.com MAGE_RUN_CODE=website2
SetEnvIf Host www\.domain2\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain2\.com MAGE_RUN_CODE=website2
SetEnvIf Host ^domain2\.com MAGE_RUN_TYPE=website

I also tried the RewriteCond/RewriteRule version.

I asked my hosting provider to add the following lines to the Nginx server, but they doesn't seem to be working, because both domains then load the default store.

fastcgi_param MAGE_RUN_CODE website1; 
fastcgi_param MAGE_RUN_TYPE website; 

fastcgi_param MAGE_RUN_CODE website2; 
fastcgi_param MAGE_RUN_TYPE website; 

I’ve set Add Store Code to Urls to No and Auto-redirect to Base URL also to No. I’ve set Use Secure URLs in Frontend to Yes and Use Secure URLs in Admin also to Yes.

In my settings under Default Config I’ve used the HTTPS version of domain1 as the base URL. The first store has als the HTTPS version as it’s base URL, and the second store has the HTTPS version of domain2. I’ve used the HTTPS version for both stores. This is because otherwise I get other redirect problems. If I use the HTTP version for both domains as it’s unsecure base URL, all pages redirect to https://www.domain.com/ or https://www.domain2.com/

I hope someone can help me. Thank you in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.