Nginx configuration location [=|~|~*|^~]/uri/{...} Usage

Source: Internet
Author: User

======

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.