smilevchy's blog

Life & Study & Chasing

Nginx_config_url_match

location smiley_019.png {

root html/image;

}

location ~.(gif|jpg|png)$ {

root E:/Pictures;

}

In this condition, it will just match the latter, nor the former, which lacks a slash( must be added if it is not regex description)


after you add it:

location /smiley_019.png {

root html/image;

}

location ~.(gif|jpg|png)$ {

root E:/Pictures;

}

In this condition, it will not match the former again because of nginx’s matching rules about location. Here, the latter will override the former.


So, you need

1.Exact Match

location = /smiley_019.png {

root html/image;

}

2.Override the match of latter regex match

location ^~ /smiley_019.png {

root html/image;

}

Thus, the former match will not be overrided by the latter.

nginx

octopress 下中文的处理 »