D
D
David Ambarsumov2017-02-09 17:18:58
Nginx
David Ambarsumov, 2017-02-09 17:18:58

NGINX how to write uri part to variable?

Hello
, please tell me how in nginx it will write part of the uri to a variable,
for example
www.somesite.com/55/7569/somepage.html,
I need to take the second path, that is, 7569 and write it to some variable for further processing, and skip the user further. I can look at
^/[0-9]*/[0-9]*/ for example, but I don't know how to get what exactly is in the second [0-9]* :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Niomin, 2017-02-09
@davidka

If you write

location ~* ^/(\d+)/(\d+)/somepage.html$ {
}

Then inside Location you will have variables $1 and $2, which will contain the corresponding numbers. For example, you can use them in try_files, or as fastcgi options.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question