Correct code for vary cookie in .htaccess?
-
Hi.
I run a site with WooCommerce & WPML. I have 2 languages, Swedish default and English as secondary. I have WPML configured using separate URL:s for each language. So when accessing Swedish language visitors is on https://www.armsportbutiken.se and on English language visitors in on https://www.armsportstore.com, even though it is the same site.
So I use currency converter widget that is only used for informational purposes, the customer always purchase with the Swedish currency SEK. But they can chose to view the prices in different currencies to estimate the cost in their local currency.
I have been reading a lot about how to make sure the currency converter choice is only for the current visitor. And cookie vary seems to be the way to go. The cookie used by the currency converter is named: woocommerce_current_currency
I have tested with adding this code to the .htaccess and have been running with this for a while:
# BEGIN CUSTOM LSCACHE SETTINGS <IfModule LiteSpeed> RewriteEngine on CacheLookup on RewriteRule .* - [E=Cache-Control:no-autoflush] RewriteRule .* - [E=Cache-Vary:woocommerce_current_currency] </IfModule> # END CUSTOM LSCACHE SETTINGS
The reason that I ask about this is that I have noticed that sometimes when I browse the site from different browsers with/without VPN enabled just to check if everything works, sometimes I see the site in a currency I haven’t chosen myself. This makes me guess that I see the currency as someone else who visited the site have chosen that currency, which is what I want to get rid off.
The code above is what I found in different forums/posts. But I also found an alternate rewrite rule:
RewriteRule .? - [E=Cache-Vary:woocommerce_current_currency]
And I don’t understand the difference between using .* or .?
So to sum up my questions:
1. Which is the correct rewrite rule? The one with .* or the one with .?
2. Is the full code above the correct code to insert to .htaccess to have vary on that cookie?
3. Where in the htaccess-file should this be placed? Does it matter where it is?So please respond like I am a child, as I have no clue what so ever about rewrite rules and .htaccess configuration.
- The topic ‘Correct code for vary cookie in .htaccess?’ is closed to new replies.