1. 默认匹配,普通匹配
location / {
root /home;
}
2. =: 精确匹配
location = /static/img/face1.png {
root /home;
}
3.~*:匹配正则表达式,不区分大小写
#符合图片的显示
location ~* .(GIF|jpg|png|jpeg) {
root /home;
}
4.~:匹配正则表达式,区分大小写
#GIF必须大写才能匹配到
location ~ .(GIF|jpg|png|jpeg) {
root /home;
}
5. ^~:以某个字符路径开头
location ^~ /static/img {
root /home;
}
6 .alias:配置别名
location /hello {
alias /home/static
}
访问 localhost/hello = localhost/home/static