V
V
v2t2014-04-09 14:36:52
Nginx
v2t, 2014-04-09 14:36:52

How to correctly compose a regular expression for nginx rewrite?

Good afternoon!
I ask for help from the regexp gurus in solving the problem. There is a link like

http://www.site.com/upload/catalog/posob/_/s/_s-1024_cover_image_small.jpeg

For some time now it has changed to
http://www.site.com/upload/catalog/posob/_/s/_s-1024_/cover_image_small.jpeg

It is necessary when trying to go to the first link to send the visitor to the second.
In this case, in place of 1024 there can be any number.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Kasymov, 2014-04-09
@v2t

location ~ /upload/catalog/posob/_/s/_s-(?<code>\d+)_cover_image_small.jpeg$ {
     rewrite ^ /upload/catalog/posob/_/s/_s-$code/cover_image_small.jpeg last;
 }


</code>


PS /code не нужен это что то тостер глючит с тегами

A
afiskon, 2014-04-09
@afiskon

eax.me/regular-expr Hope this helps.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question