0

I am working on a Magento 2.2.7 running on Apache/Linux/Cloudways. Before I started working here, three websites were already setup to run on a single magento instance. Microbattery.com , HearingAidBatteryShop.com, and cochlearbatteries.com. I am now trying to add a third site using the magento backend. I created the website, store and storeview for hearing-aid-batteries.com and its pointed to our servers. I modified the rewrites in the .htaccess file of my magento directory but hearing-aid-batteries.com is redirecting to microbattery.com for some reason.

I have tried the following: php bin/magento cache:clean php bin/magento cache:flush rm -rf var/cache/* php bin/magento reindexer:index

I checked the tmp director to see if any cache files were being stored in there.

I changed the base url for hearing-aid-batteries.com to http://hearing-aid-batteries.com

All of these things still result in the same issue.

hearing-aid-batteries.com redirects to microbattery.com

.htaccess and sitemap config

SetEnvIf Host wwww\.hearing-aid-batteries\.com MAGE_RUN_CODE=habaffiliate
SetEnvIf Host staging\.hearing-aid-batteries\.com MAGE_RUN_CODE=habaffiliate
SetEnvIf Host www\.hearing-aid-batteries\.com MAGE_RUN_TYPE=website
setEnvIf Host staging.\hearing-aid-batteries\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^hearing-aid-batteries\.com MAGE_RUN_CODE=habaffiliate
SetEnvIf Host ^hearing-aid-batteries\.com MAGE_RUN_TYPE=website


RewriteCond %{HTTP_HOST} ^.*hearing-aid-batteries\.com$
RewriteRule ^sitemap.xml$ /aff/sitemap.xml [NC,L,R=301]


RewriteCond %{HTTP_HOST} ^hearing-aid-batteries.com [NC]
RewriteRule ^(.*)$ https://www.hearing-aid-batteries.com/$1 [L,R=301,NC]
  • make sure you have correct base url, run cli comman to list websites and codes – MagenX Aug 7 at 19:33
  • while staging is redirected too – MagenX Aug 7 at 19:35
  • @MagenX , the base url is correct in magento admin – Steve Bien-Aime Aug 8 at 17:09
0

Have you considered editing index.php

Similar to what's shown in this example

https://magento.stackexchange.com/a/183980/70343

It worked for us on a problem install

  • How will this affect the existing sites .? – Steve Bien-Aime Aug 7 at 16:42
  • That's what the domain switch statement is about – Dominic Xigen Aug 7 at 17:32
  • I'll try that , but its really weird that the first three sites are working but not this one . Also , these settings work on the staging server without issue – Steve Bien-Aime Aug 8 at 17:29
0

turns out the error was a simple typo. if you look at my initial post:

I typed : SetEnvIf Host wwww.hearing-aid-batteries.com MAGE_RUN_CODE=habaffiliate

there is an extra

w

in the url which caused cloudways to auto redirect to the main site since there was no redirect found for the actual url : www.hearing-aid-batteries.com (with 3 w's )

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.