======
Nginx location Syntax
Basic syntax: location [=|~|~*|^~]/uri/{...}
= Strict match. If the query matches, the search is stopped and the request is processed immediately.
~ For case-sensitive matching (Regular expressions available)
!~ to match case
~* for case-insensitive matching (regular expressions available)
!~* does not match case-insensitive
^~ If you use this prefix for a regular string, then tell Nginx if the path matches then do not test the regular expression.
Example
=====
Location =/{
# Match/Query only.
}
Location/{
# matches any query, because all requests have/begin. However, regular expression rules and long block rules will be matched by precedence and query.
}
Location ^~/images/{
# matches any query that has/images/start and stops the search. Any regular expression will not be tested.
}
Location ~*. (Gif|jpg|jpeg) $ {
# matches any request that has a GIF, JPG, or JPEG end.
}
Location ~*. (gif|jpg|swf) $ {
Valid_referers none blocked start.igrow.cn sta.igrow.cn;
if ($invalid _referer) {
#防盗链
Rewrite ^/http:/$host/logo.png;
}
}
====
Reference: http://www.php100.com/html/program/nginx/2013/0905/5535.html
Nginx configuration location [=|~|~*|^~]/uri/{...} Usage