location指令
原创2026/3/5小于 1 分钟
server {
listen 8000;
server_name somename alias another.alias;
location / {
root html;
index index.html index.html;
}
}语法:location [ = | ~ | ~* | ^~] uri { ... }
| 匹配规则 | 含义 | 示例 |
|---|---|---|
= | 精确匹配 | location = /images/ {...} |
~ | 正则匹配,区分大小写 | location ~ .(jpg )$ {...} |
~* | 正则匹配,不区分大小写 | location ~* .(jpg )$ {...} |
^~ | 匹配到即停止搜索 | location ^~ /images/ {...} |
| 不带任何符号 | location / {...} |
至此,本章节的学习就到此结束了,如有疑惑,可对接技术客服进行相关咨询。