Location means "positioning", which is mainly based on Uri for different positioning. It is essential in the configuration of virtual hosts. Location can locate different parts of the website to different processing methods. 1. Basic syntax of location location [=|~|~*|^~] patt { } =: Strict match. If the query matches, the search stops and the request is processed immediately. ~: for case-sensitive matching (regular expressions can be used). ~*: for case-insensitive matching (regular expressions can be used). ^~: If you use this prefix with a regular string, it tells nginx not to test the regular expression if the path matches. 2. How location works 3. Simple examples prove the conclusions of the above pictures Matching process without regular expressions location = / { root /var/www/html/; index index.htm index.html; } location / { root /usr/local/nginx/html; index index.html index.htm; } The location configuration is as above. If you visit http://xxx.com/, the positioning process is: Matching process with regular expressions 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, the uri is "/image/logo.png", which matches the common match "/" and the regular match "~ image". However, according to the matching process analysis in the above picture, the regular match is finally effective. 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 the "root /var/www/" in the regular expression to "alias /var/www/" The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: The difference and execution method of select count() and select count(1)
>>: Two ideas for implementing database horizontal segmentation
Table of contents Overview Hash Properties Host p...
Now 2016 server supports multi-site https service...
In this article, we would like to share with you ...
app.js: startup file, or entry file package.json:...
This article shares with you the installation tut...
What is a generator? A generator is some code tha...
Compatible with new CSS3 properties In CSS3, we c...
Method 1: Set the readonly attribute to true. INPU...
If you have a choice, you should use UTF-8 In fac...
After three days of encountering various difficul...
Use Nginx to build Tomcat9 cluster and Redis to r...
123WORDPRESS.COM has explained to you the install...
Two methods to implement Mysql remote connection ...
Table of contents 1. Background 2. Understanding ...
This article shares the specific code for using j...