Score:0

Nginx custom 301 rewrite

be flag

I am struggling to find how to write this scenario 301 redirect to nginx:

https://mydomain/$

to be converted

https://mydomain/en_us/$

Actually I need to add "en_us" just after mydomain and just before my dynamic urls

What I tried is this:

location /
          {
             rewrite ^(/.*)/ $1/en_us/$ last;
          }

But no luck

Any help please?

sv flag
What have you tried so far?
G. G. avatar
be flag
@PothiKalimuthu I updated the question
us flag
Please add output of `nginx -T` to the question. Please also add what does "no luck" mean. What command did you try, what was the expected result and what was the actual result?
sv flag
@G.G. A similar question and solution is provided at https://serverfault.com/a/1122830/102173 . Good luck!
Score:0
be flag

Fixed with this:

rewrite "^/(?!admin|en_us|stripe)(.*)" /en_us/$1 permanent;

Inside ()

you can put whatever word contained in url which needs to be excluded.

Also if you use nginx as proxy don't forget to use:

port_in_redirect off;

So the port won't transfered in the redirect

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.