I want to remove a query string but only for the 6 cases below and never for any subfolders / other url's.
http://www.example.com/?___store=de&___from_store=de
http://www.example.com/?___store=de&___from_store=en
http://www.example.com/en/?___store=de&___from_store=en
http://www.example.com/en/?___store=de&___from_store=en
http://www.example.com/en/?___from_store=en
https//www.example.com/en/?___from_store=de
This is what I already got. It's working, but removes the query string from all url's, what I don't want.
RewriteCond %{QUERY_STRING} /?___store=de&___from_store=de
RewriteRule ^(.*)$ /$1? [L,R=301]
RewriteCond %{QUERY_STRING} /?___from_store=de
RewriteRule ^(.*)$ /$1? [L,R=301]
RewriteCond %{QUERY_STRING} /?___store=de&___from_store=en
RewriteRule ^(.*)$ /$1? [L,R=301]
RewriteCond %{QUERY_STRING} /?___from_store=en
RewriteRule ^(.*)$ /$1? [L,R=301]
I need this specific rewrite rule for a Magento shop. The store view code of the default store is removed by this extension: Knectar/Magento-Store-Codes, see also this: Magento remove store code for default store view. As a result, the ___store query parameter is added to the url, but only on root.
My solution above does not work, because when it comes to products / categories the language switch is not working correctly anymore (and there is no need to remove the string, because it is stripped out by Magento itself).