A
A
ant212018-04-02 16:37:19
Nginx
ant21, 2018-04-02 16:37:19

How to make a conditional redirect using NGINX?

Good day. Transferred articles from the old site to the new one (Wordpress). When importing, post IDs moved a little, but at the same time, posts have labels like id-1000 (the number is the real old ID). The URL structure itself has been preserved, but the IDs have shifted.
Link structure site.ru/cat/article/1012
At the same time, the label will be mysite.com/id-1000 There
are a lot of posts, more than 20,000. Is it possible to do a conditional redirect using nginx?
X is the last ID to be redirected.
site.ru/cat/article /N If N <= X execute 301 on mysite.com/id-N
It turns out that for old posts with IDs up to X inclusive, you need to do a redirect, but not for the rest. Spreading a regular URL is not a question, how to do the comparison itself?
Sorry if it was messy.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2018-04-02
@BorisKorobkov

nginx.org/ru/docs/http/ngx_http_rewrite_module.html
PS Just don't use if

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question