Copyright Notice: Https://github.com/wusuopubupt
======
Nginx location Syntax
Basic syntax: location [=|~|~*|^~]/uri/{...}
= Strict match. If the query matches, the search is stopped and the request is processed immediately.
~ Case-sensitive matching (regular expression 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 start with/. However, regular expression rules and long block rules will be matched by precedence and query.
}
Location ^~/images/{
# matches any query that starts with/images/and stops the search. Any regular expression will not be tested.
}
Location ~*. (Gif|jpg|jpeg) $ {
# matches any request that ends with a gif, JPG, or JPEG.
}
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