Multi-Store/Currency Auto Switcher Not Redirecting To Correct Page
Problem
Some multi-store/currency setups use an auto switcher, such as Extendware's Store / Currency Switcher, which gracefully redirects customers to the proper store and currency based on their geographic location and browser configuration. With LiteMage on, this function doesn't always work as expected.
Cause
In order to determine which store and currency a customer should be redirected to, the customers first request must hit the backend so that the proper cookie can be set. Without this cookie, the default store will be served from cache instead. LiteMage default configuration doesn't check whether the request is the first one and so the cookie is never set.
Solution
To fix this behavior, we need to force the customer's first request to hit the Magento backend. To achieve this, add the following rewrite rules to your .htaccess
file:
RewriteCond %{HTTP_COOKIE} !frontend RewriteCond %{HTTP_USER_AGENT} !(litemage_walker|googlebot|bingbot|googlebot|yahoo) [NC] RewriteRule .* - [E=Cache-Control:vary=hitback,E=Cache-Control:no-cache]
These rules will check if the “frontend” cookie is not set, which will always be the case on a customers first visit, and if the user agent is not a bot. If these conditions are met, then force the request to hit the backend using a fake cookie vary.
Notes
In order for LiteMage's crawler to properly crawl your multiple currencies/stores, you must also add /litemage_walker/
to your auto switcher's disabled user agents list.
In Extendware's Store / Currency Switcher, you can disable auto-switching for any user agents matching an input regular expression. Simply navigate to Disabled User Agents > User Agent RegExp and add /litemage_walker/
.