背景

      一直没明白这个配置啥意思,反正凑合用吧,不过老凑合总不是个事,没搞明白更容易忘,别人问还答不上来。反正也很简单,就搞明白点记下来。

知识点

root实例: 

location ^~ /t/ {
     root /www/root/html/;
}

如果一个请求的URI是/t/a.html时,web服务器将会返回服务器上的/www/root/html/t/a.html的文件。 

alias实例: 

location ^~ /t/ {
 alias /www/root/html/new_t/;
}

如果一个请求的URI是/t/a.html时,web服务器将会返回服务器上的/www/root/html/new_t/a.html的文件。注意这里是new_t,因为alias会把location后面配置的路径丢弃掉,把当前匹配到的目录指向到指定的目录。 

注意:

1. 使用alias时,目录名后面一定要加"/"。
3. alias在使用正则匹配时,必须捕捉要匹配的内容并在指定的内容处使用。
4. alias只能位于location块中。(root可以不放在location中)

相关文章:

  • 2021-11-12
  • 2021-10-19
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-10-28
  • 2022-12-23
猜你喜欢
  • 2021-10-02
  • 2021-10-22
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案