Answer the question
In order to leave comments, you need to log in
How to return images by ID and any name?
Hello.
In general, the task is this: on the server, all the pictures are numbered and lie in the /img folder, how to make it so that when requested:
domain.com/custom/url/luboe_nazvanie_pic12975_etc.jpg
/img/12975.jpg
if ($uri ~ pic(\d+)) {
set $pic_id $1;
}
location /custom/url {
root /img;
access_log off;
autoindex off;
expires 30d;
add_header Cache-Control "public, no-transform";
}
Answer the question
In order to leave comments, you need to log in
rewrite "^\/custom\/url\/.*([0-9]+).*\.jpg$" "/img/$1.jpg" break;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question