We have a magento store which appends a query to our URL when you change Magento store views on the frontend.

i.e. http://www.domain.com/?___store=uken

Is there a way to remove the ?___store=uken with NGINX configuration? Say remove any query beginning with ?___store=. I'm very new to server config & nginx in particular.

  • Please refer to this post. I think this is what you need. The original nginx reference page is here. – ngn Jul 21 '15 at 8:50
  • 1
    If this is the default behaviour of Magento, then Http rewrite may end up affecting functionality. Magento needs to be configured to use POST requests instead of GET so that query parameters are not explicitly visible. – ngn Jul 21 '15 at 8:54
  • @ngn, I think you're right. I'm over thinking it and should probably leave the magento default behavior alone. I've also realized that the query string is only appended when the user switches stores. – Holly Jul 21 '15 at 8:56

If you need to delete the querystring __store= from the URL you have to clear the variable $args and then rewrite the main location.

Try to use this rule to delete the querystring from the url:

location / {
    set $args '';
    rewrite ^/(.*)$ /$1 permanent;

or if you have a website url like: http://www.mystore.com/shop/index.php?__store=en you can rewrite the new location with:

location /shop {
    set $args '';
    rewrite ^/shop/(.*)$ /shop/$1 permanent;

If you want to remove a specific parameter from multiples:

if ($request_uri ~ "([^\?]*)\?(.*)_=([^&]*)&?(.*)") {
    set $original_path $1; 
    set $args1 $2; 
    set $unwanted $3; 
    set $args2 $4; 
    set $args ""; 

    rewrite ^ "${original_path}?${args1}${args2}" permanent;

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.