P
P
Pavel Osipov2012-03-15 12:07:50
Nginx
Pavel Osipov, 2012-03-15 12:07:50

Rewrite rule for Nginx

Hi people.
There was a problem, due to inexperience in configuring Nginx I can not handle it myself.

There is a site, it has one of the subfolders:
/customer_data/pictures/
it has more subfolders, but this is not so important. For example: customer_data/pictures/2008/07/30/a_1/places/13496/4c718.jpg

The names of the target file can be one of three: 4c718.jpg, big_4c718.jpg and sm_4c718.jpg

And the task is to add arbitrary text to the file name different languages. Those. write a rewrite something like this:

customer_data/pictures/2008/07/30/a_1/places/13496/__photo of my grandmother__4c718.jpg
Moreover, you can choose which separator of the additional text is convenient.

Based on the materials of this article, I tried, but something somewhere does not fit.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hint, 2012-03-15
@Hint

rewrite "^(.*/)([^/]*__)?((big_|sm_)?[a-z\d]+\.(jpg|gif|png))$" $1$3 last;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question