A: Location-detailed precision matching
Location syntax
Location has the meaning of "positioning", depending on the URI for different positioning.
In the configuration of the virtual host, is essential, location can be the different parts of the site, to different processing methods.
For example, how do I invoke the PHP interpreter when I encounter. php? --then you need location.
The syntax of location
Location [=|~|~*|^~] Patt {
}
The brackets can not write any arguments, which is called a generic match at this time
You can also write parameters
Therefore, the large type can be divided into 3 kinds
Location = Patt {} [exact match]
Location patt{} [General match]
Location ~ patt{} [regular match]
How does it work?:
First see if there is an exact match, and if so, stop the matching process.
Location = Patt {
Config A
}
if $uri = = Patt, match successfully, use Configa
Location =/{
root/var/www/html/;
Index index.htm index.html;
}
Location/{
root/usr/local/nginx/html;
Index index.html index.htm;
}
If you access http://xxx.com/
The positioning process is
1: Precision match in "/", get index page to index.htm
2: Visit/index.htm again, this internal jump URI is already "/index.htm",
root directory is/usr/local/nginx/html
3: The end result, visited/usr/local/nginx/html/index.htm
The exact match of Nginx location detailed