0

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).

1 Answer 1

1

Try the following:

RewriteCond %{QUERY_STRING} ^___store=de&___from_store=(en|de)$ [NC]
RewriteRule ^(en/?)?$ $1? [R=301,L,NC]

RewriteCond %{QUERY_STRING} ^___from_store=(en|de)$ [NC]
RewriteRule ^en/?$ $0? [R=301,L,NC]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.