Score:0

NGINX rewrite url with arg

ec flag

We need to check if a URL contains a specific arg "?___store=en" and then redirect to the same url, but add /en/ after the domain name. But this should be dynamic, because the url is not static and should be able to change from every specific page.

For example:

https://www.example.com/category1/product1?___store=en

Should be redirect to:

https://www.example.com/en/category1/product1

We already tried the following, but we are missing the dynamic part, because this rewrite to the homepage;

if ($arg____store = "en") {
    rewrite ^(.*) /en/? permanent;
}
Richard Smith avatar
jp flag
Try: `rewrite ^/(.*)$ /en/$1? permanent;`
JGeer avatar
ec flag
@RichardSmith Thanks! Works perfect
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.