In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
basic knowledge
The matching order of location is "match regular first, then match ordinary".
The matching order of location is actually "match ordinary first, match regular". The reason for this misunderstanding is that regular matches override ordinary matches.
Nginx location configuration syntax
1. location [ = | ~ | ~* | ^~ ] uri { ... }
2. location @name { ... }
Location configuration can be configured in two ways
1. prefix + uri (string/regular expression)
2.@ + name
Prefix Meaning
=: Exact match (all must be equal)
~: Case sensitive
~*: ignore case
^~: Only match uri part
@: Internal Service Jump
Location Basics
1. Location is configured in the server block.
2. You can use different configurations (in location) to process different requests based on different URIs.
3. Location is sequential and will be processed by the first matching location.
Location Configuration demo
1.=,exact match
location = / { #rule} #matches to `http://www.example.com/` such a request.
2.~,case sensitive
location ~ /Example/ { #rule} #request example #http://www.example.com/Example/ [success] #http://www.example.com/example/ [failure]
3.~*,Case ignored
location ~* /Example/ { #rule} #the uri case is ignored #http://www.example.com/Example/ [success] #http://www.example.com/example/ [success]
4.^~,Matches only if they start with uri
location ^~ /img/ { #Rule} #Requests that start with/img/will match #http://www.example.com/img/a.jpg [success] #http://www.example.com/img/b.mp4 [success]
5.@,nginx internal jump
location /img/ { error_page 404@img_err; } location @img_err { #rule} #Requests that begin with/img/if the link's status is 404. It matches the @img_err rule.
summary
Location in Nginx is not as difficult to understand as you think, so don't be afraid. Find more information and try more. You'll get something.
reference
http://nginx.org/en/docs/http/ngx_http_core_module.html#locationUniform Resource Identifier
Well, the above is the whole content of this article, I hope the content of this article has a certain reference value for everyone's study or work, if you have questions, you can leave a message to exchange, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.