has been in Meng Nginx routing configuration, after a few hours today's efforts to finally understand.
If there is a wrong place, I hope that the predecessors pointed out the wrong, let me a higher level, but also let me not to go the wrong way farther.
1.index
My understanding is the default path, which is when a file cannot be found with a default path that can be configured multiple.
The specific usage later says, please remember this thing first when you can not find the other suitable thing, the default assigns to you.
2.location
This thing matches the path you need.
Server {
Listen
server_name localhost
root html/
index index.html index.htm index.php;
location/{
try_files $uri $uri//index.php? $a RGs
Proxy_pass http://www.baidu.com;
}
location ~ \. (html|htm) $ {
try_files $uri = 404
}
Location ~ \.php$ {
Try_files $uri = 404;< br> include fastcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
}
}
You can match all the URIs you need.
Want to be specific about it. Http://www.nginx.cn/115.html
3.try_files
This thing is redirected, and I feel like index, but it works better than index.
As an example:
Visit: XF.COM/AA
If we set this up, the understanding of this sentence is.
Try_files $uri $uri//index.php $args;
When Nginx receives your XF.COM/AA, it will match up to
Location/{
Try_files $uri $uri//index.php $args;
Proxy_pass http://www.baidu.com;
}
Here is a mouth, if there is no suitable match, then will find the value of index.
Index.html inde.htm index.php
When the corresponding file is found, your access URL will be changed to.
xf.com/index.html or xf.com/index.htm xf.com/index.php one of them.
You understand the index this time?
Come back, we'll talk try_files.
When this is matched, the try_files is executed.
Nginx go back to find out if there's a AA this file ($uri) if not
Continue to find a AA this directory ($uri/) if not, then directly
Redirect to/index.php? $args
$args is your URL, the argument behind the question mark.
Summarize:
Nginx Get to URL
1. Find server_name
2. Find Locationpipei
If the index default file is not found
If not directly 404
Some words plus the default index.* to find a matching location
If there is entry into the executive Try_files
3. Find out if Try_files has the appropriate file
If the last item is not directly redirected