标签:nbsp 特殊字符 config pytho 官方 区别 bsp 不同的应用 oca
location作用
location的作用是根据用户请求的URL来执行不同的应用。根据用户请求的网站地址URL进行匹配,匹配成功
即进行相关操作。
location语法
#语法
location [ = | ~ | ~* | ^~ ] url {
...
}
#说明
location 指令
[=|~|~*|@] 匹配标识
url 匹配的网站网址
{...} 匹配URL后要执行的配置段
#匹配这两种特殊字符 “~”或“~*”的区别:
“~”用于区分大小写(大小写敏感)匹配
"~*"用于不区分大小写的匹配
"!"对上面的匹配取反,如("!~"和"!~*")
"^"作用是在进行常规的字符匹配后,不做正则表达式检查
location匹配示例
#官方例子
location = /{
[ configuration A ]
}
#用户请求URL:/
#完整URL:http://www.hello.com/
location /{
[ configuration B ]
}
#用户请求URL:/index.html
#完整URL:http://www.hello.com/
location /documents/ {
[ configuration C ]
}
#用户请求URL:/documents/document.html
#完整URL:http://www.hello.com/documents/document.html
location ^~ /images/ {
[ configuration D ]
}
#用户请求URL:/images/1.gif
#完整URL:http://www.hello.com/images/1.gif
location ~* \.(gif|jpg|jpge)$ {
[ configuration E ]
}
#用户请求URL:/documents/1.gif
#完整URL:http://www.hello.com/documents/1.gif
标签:nbsp 特殊字符 config pytho 官方 区别 bsp 不同的应用 oca
原文地址:https://www.cnblogs.com/hulue/p/9176864.html