location ^~ /location {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
完整的解释是:try_files 去尝试到网站目录读取用户访问的文件,如果第一个变量存在,就直接返回;不存在继续读取第二个变量,如果存在,直接返回;不存在直接跳转到第三个参数上。变量就是每个uri资源。并不改变请求路径。 $uri表示文件资源, $uri/表示目录资源。
location ^~ /location {
root /usr/share/nginx/html;
index index.html index.htm;
rewrite http://www.baidu.com break;
}
请求location,跳转至百度,改变请求路径。break表示不再向下匹配。
