Home > Blockchain >  Nginx redirect dynamic page
Nginx redirect dynamic page

Time:11-13

I want to redirect the dynamic URL when a user accidentally delete /en

for e.g

https://myweb.com/en/product/myproduct-1
https://myweb.com/en/product/myproduct-2
https://myweb.com/en/product/myproduct-3

so when the user accidentally deletes /en then he is still redirected to the web it should be like this:

https://myweb.com/en/product/myproduct-1

not like this

https://myweb.com/product/myproduct-1

I've tried like this but failed:

location /produk/[a-zA-Z0-9|-]* {
     return 301 https://myweb.com/end/about/[a-zA-Z0-9|-]*;
}

how to do the redirect dynamically without having to go one by one, because there are many product pages?

CodePudding user response:

Solve by this:

location ^~ /product/ { return 301 /en$request_uri; }
  • Related