Remove query string from url

9,822

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;
}
Share:
9,822

Related videos on Youtube

Holly
Author by

Holly

I am a user who prefers to keep an air of mystery about myself, apparently.

Updated on September 18, 2022

Comments

  • Holly
    Holly over 1 year

    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.

    • ngn
      ngn almost 9 years
      Please refer to this post. I think this is what you need. The original nginx reference page is here.
    • ngn
      ngn almost 9 years
      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.
    • Holly
      Holly almost 9 years
      @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.
  • Andrew Schulman
    Andrew Schulman about 6 years
    Please add some explanation.
  • Cavid Muradov
    Cavid Muradov about 6 years
    @AndrewSchulman done!