I have two folders with the file: / var / www / imagestest and / var / www / imagestest2 in folder 2 files Can be stored or divided by num. For example, request uri /images/0/1.jpg file can be stored in /var/www/imagestest2/images/0/0/0/1.jpg. Regular expression is fine, but I can not sometimes configure nginx to work with all the folders, and get 404 again for repeated yuri.
File structure:
/ var / www / Imagestest2 / images / 2.jpg / var / www / imagestest2 / images / 0/0/0/0/1 .jpg
request:
is as:
curl-I imagestest.local / images / 2.jpg HTTP / 1.1 200 OK
file / var / www / imagestest2 / 0/0/0/0 / 1.jpg:
curl-I imagestest.local / Images / 0 / 1.jpg # HTTP / 1.1 404 not found
as splitted in dir:
curl -i imagestest.local / images / 0/0/0/0 / 1.jpg HTTP / 1.1 404 Not Found
Nginx Configuration:
Server {listen *: 80; Server_name imagestest.local; Root / var / www / imagestest /; $ Other_dir Set "/ var / www / imagestest2"; Place ~ / {try_files $ uri @other_dir = 404; Error_page 404 = @Chrite; } #try files @other_dir {root $ other_dir; } # Try Splitted Location @rewrite {Route $ other_dir; Rewrite "^ / (. *) \ / ([0-9] {1,3}) / / (. *)" "/ $ 1/0/0 / $ 2 / $ 3" last; # 1-3}}
But if I want to rewrite the site block and server block - I will be flashed to 200 OK, but files from folder / var / www / imagestest Can not obtain /:
curl-I imagestest.local / images / 0 / 1.jpg HTTP / 1.1 200 OK server {listen *: 80; Server_name imagestest.local; Root / var / www / imagestest2 /; $ Other_dir Set "/ var / www / imagestest2"; Rewrite "^ / (. *) \ / ([0-9] {1,3}) / / (. *)" "/ $ 1/0/0 / $ 2 / $ 3" last; # 1-3 .....
Comments
Post a Comment