1

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.

Holly
  • 1,027
  • 5
  • 14
  • 25
  • Please refer to [this](http://stackoverflow.com/questions/9641603/remove-parameters-within-nginx-rewrite) post. I think this is what you need. The original nginx reference page is [here](http://wiki.nginx.org/HttpRewriteModule#rewrite). – ngn Jul 21 '15 at 08: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 08: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 08:56

2 Answers2

2

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;
}
Michelangelo
  • 260
  • 2
  • 13
0

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;
}
Siwei
  • 99
  • 4