E
E
Eugene2016-10-01 21:55:40
Nginx
Eugene, 2016-10-01 21:55:40

How to correctly change paths in nginx to statics?

Good day!
Please help in solving the following problem: It is
required to solve the problem in such a way that the statics on the site look like
/storage/2b52c5ae/QIEARQ8ieqGDfdGa.jpg
, where 2b52c5ae - 4 folders, divided by 2 characters, example 2b/52/c5/ae :

/home/evgeny/project/storage/app/images/2b/52/c5/ae/QIEARQ8ieqGDfdGa.jpg

How can I set up the /storage location correctly?
location /storage {
        root /home/evgeny/project/storage/app/images;
}

Is it possible by changing the location section code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2016-10-01
@romy4

I'm not sure that this is fully working, but catch the train of thought. and possibly working

location ~ /storage/(.{2})(.{2})(.{2})(.{2})/(.*)\.(jpg|png|gif)$ {
    root /home/evgeny/project/storage/app/images/$1/$2/$3/$4;
    try_files $5;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question