In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "sample analysis of the Location configuration of Nginx", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of the Location configuration of Nginx".
Location has the meaning of positioning, mainly according to the Uri to carry out different positioning. In the configuration of virtual host, it is essential.
Location can locate different parts of the site in different ways.
The basic syntax of 1.location
Location [= | ~ | ~ * | ^ ~] patt {} =: a strict match. If the query matches, the search is stopped and the request is processed immediately. ~: for case-sensitive matching (regular expressions are available). ~ *: for case-insensitive matching (regular expressions are available). ^ ~: if you use this prefix for a regular string, tell nginx not to test the regular expression if the path matches.
How 2.location works
3. A simple example proves the conclusion of the above picture.
Matching process without regular expression
Location = / {root / var/www/html/; index index.htm index.html;} location / {root / usr/local/nginx/html; index index.html index.htm;}
Location is configured as above. If you access http://xxx.com/, the positioning process is as follows:
1: the exact match hits "/", and the index page is index.htm, so the requested address becomes http://xxx.com/index.htm.
2: match "/ index.htm" again. The internal transfer uri is already "/ index.htm", hit the normal match "/", and the root directory is / usr/local/nginx/html.
3: final result, visited / usr/local/nginx/html/index.htm
Matching process with regular expression
Location / {root / usr/local/nginx/html; index index.html index.htm;} location ~ image {root / var/www/; index index.html;}
If we visit http://xx.com/image/logo.png. At this time, uri hits both the normal match "/" and the regular match "~ image" for "/ image/logo.png". However, according to the analysis of the matching process in the above image, the regular match finally takes effect.
So the final access address is: / var/www/image/logo.png. If you want the final matching path to be / var/www/logo.png, you can change "root / var/www/" in regular matching to "alias / var/www/".
The above is all the contents of the article "sample Analysis of Location configuration of Nginx". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.