nginx的location详解
属于nginx核心模块中的功能,nginx核心功能.
location用于匹配用户请求中的uri的.
root /app/code/www/
www.oldboylinux.cn uri:/
/app/code/www/首页文件.
www.oldboylinux.cn/index.html uri:/index.html
/app/code/www/index.html
www.oldboylinux.cn/oldboy/lidao.jpg
uri:/oldboy/lidao.jpg
/app/code/www
2) 匹配规则
优先级:(了解)
正则: 用符号匹配有规律的内容.^ $ . * [] []+ | ()
server {
listen 80;
server_name l.oldboylinux.cn;
default_type text/html;
location / {
return 200 "location /\n";
}
location = /index.html {
return 200 "location =/\n";
}
location ~ /index.html {
return 200 "location ~/\n";
}
location ^~ /index.html {
return 200 "location ^~\n";
}
}