A
A
Andrey Tumanchik2017-05-31 17:13:23
Nginx
Andrey Tumanchik, 2017-05-31 17:13:23

Nginx how to gracefully write 300 redirects?

Good day to all.
I had a problem on a seemingly simple task. I have about 300 redirects in the blog section of the form:

/blog?page=post&blog=blog_EN&id=298 /blog/topic1-theme-for-russian-speakers/
/blog?page=post&blog=blog_RU&id=300 /blog/webinar-new-staff/

As I understand it, here location is "blog" and then $args.
I managed to do this through a map view:
map $args $link { 
"blog?page=post&blog=blog_EN&id=300" "/blog/webinar-new-staff/"; 
.... 
default "/blog/"; 
}

and
if ($args) { 
return 301 $scheme://$host$link; 
}

Everything is working. But a map of three hundred entries seems cumbersome to me.
Are there any solutions to the problem that are more elegant than mine?
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Erelecano Oioraen, 2017-06-01
@Erelecano

https://www.nginx.com/resources/wiki/start/topics/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question