Reputation: 1607
*******************************solved*****************************
location ~ ^/images/(.+\.(?:gif|jpe?g|png))$
{
include /etc/nginx/mime.types;
alias /site/$1;
}
Not certain but I needed to add $1 to the end and changed the regex a little.
I have a route set up how do I only serve up png and jpg files. Currently it serves up any extension.
location /image {
alias /site/;
}
I've tired the following but received errors.
location /image \.(png|jpg)
{
alias /site/;
}
I just want to show only png and jpg files in the directory. Moving the files isn't an option. A lot of sub directories with images.
I've tried
location ~* ^/image/.+\.(png|jpg)$
I am getting no errors but the images aren't showing. Yes the images are in the folder.
*********************** update *************************
This location block works if I put a redirect in the block. But if I try to show the image via
location ~* /images2/.+\.(png|jpg)$
{
}
The error logs says the following
GET /images2/flowers/type/T.png/ HTTP/1.1" 404 209
Upvotes: 1
Views: 2454
Reputation: 1607
*******************************solved*****************************
location ~ ^/images/(.+\.(?:gif|jpe?g|png))$
{
include /etc/nginx/mime.types;
alias /site/$1;
}
Not certain but I needed to add $1 to the end and changed the regex a little.
Upvotes: 2