R
R
Rukis2017-10-14 11:03:08
PHP
Rukis, 2017-10-14 11:03:08

How to keep the old image urls when changing their paths?

After restructuring the directory with images, their paths will change as follows:

Сейчас:
/5aefce2c8ec8f389ea4ec77ec1b90a34.jpg
/45149b36b87bdabdf64ce789c105e441.jpg
/a077e9957f2265798d9cacc0133c6268.jpg

Будет:
/5a/5aefce2c8ec8f389ea4ec77ec1b90a34.jpg
/45/45149b36b87bdabdf64ce789c105e441.jpg
/a0/a077e9957f2265798d9cacc0133c6268.jpg

That is, each file will be moved to a subfolder named by the first two characters of its name.
It is required to keep the availability of images at the same url.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Misty Hedgehog, 2017-10-14
@paramtamtam

nginx-rewrite returning a permanent redirect and cutting out all the old links won't work in your case?

V
Vladimir Mukovoz, 2017-10-14
@castomi

You can make a regular expression in Nginx and the paths will be saved. Just need more data to make it up. Rather, you need more data so that the compiled regular season does not break something else) You need to look at the structure of the site and the virtual host.
https://nginx.ru/ru/docs/http/ngx_http_rewrite_mod...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question