1

I have this url:

https://example.com/admin/catalog/product/view/id/45533/?___store=en_us&sendAttributionID=email_automation_5ffa6c5967af4527508858fb&ContactID=5f9d9eac1215fsdfsdfasdffsdfsdf04ff6c98af

I need to redirect it with nginx to:

https://example.com/catalog/product/view/id/45533/?___store=el_gr&sendAttributionID=email_automation_5ffa6c5967af4527508858fb&ContactID=5f9d9eac1215fsdfsdfasdffsdfsdf04ff6c98af

In fact I need from first link: To remove

admin

and replace:

en_us

with:

el_gr

I have this regex for now:

rewrite ^/admin/(.*)$ https://example.com/$1 permanent;

which removes the admin word. But I can't figure out how to replace the

en_us

After UML help now I am in:

rewrite ^/admin/(.*?)en_us(.*?)$ https://example.com/$1el_gr$2 permanent;

which in Online Regex works but not in nginx

Any help please?

G. G.
  • 143
  • 6

1 Answers1

1

EDITED

I first thought that just changing the regex would help, like this:

rewrite ^/admin/(.*?)___store=en_us(.*)$ https://example.com/$1___store=el_gr$2 permanent;

However, as the rewrite matching only works on the "filename" part (up to ?), it won't work. Some other technique is required.

UML
  • 11
  • 2
  • Thank UML. Unfortunately this regex is returning the initial link. Is not affecting anything – G. G. Jan 10 '21 at 20:24
  • Okay, I have investigated the situation more. This won't work, as only the first part of the string (up to ?) is evaluated by the rewrite module. Maybe this answer can help: https://serverfault.com/questions/160790/nginx-rewrite-for-an-url-with-parameters – UML Jan 10 '21 at 21:31
  • UML check my question again please....I just edited – G. G. Jan 10 '21 at 21:32