nginx location中root指令和alias指令的区别
nginx location中root指令和alias指令
功能:将url映射为文件路径,以返回静态文件内容
差别:root会将完整的url映射进文件路径中
alias只会将location后的url映射到文件路径中
|
location /root { root html; } 当访问为http://192.168.25.35/root/hello.html时 会将url --> root/hello.html拼接在root指令的值html下 即会在路径html/root/html/hello.html下找资源,如果找到则返回资源内容 如果找不到则返回404错误 再如 访问http://192.168.25.35/a/b/c.html "/usr/local/nginx/html/a/b/c.html" failed (2: No such file or directory) location /alias { alias html; index index.html index.htm; } 当访问http://192.168.25.35/alias/a/hello.html时 会将location后的url---> a/hello.html(注意不包括location后 /alias 路径)拼接在 alias指令值html后,即html/a/hello.html下找资源 再如 http://192.168.25.35/alias/location/index/ "/usr/local/nginx/html/location/index/index.html" is not found (2: No such file or directory) http://192.168.25.35/alias/location/index "/usr/local/nginx/html/location/index" failed (2: No such file or directory) 通过以上报错信息得知,url后有/时,会默认找index.html资源 当url访问目录并以 / 结尾,则nginx默认会返回index指令配的文件内容 当index指定一个不存在的文件,autoindex on时,url访问目录并以 / 结尾时,返回文件目录 location /alias { 当访问http://192.168.25.35/alias/时,将返回html下的文件目录结构 |
nginx location中root指令和alias指令的区别的更多相关文章
- nginx 的 content阶段的root指令与alias指令
root 与alias指令 Syntax: alias path; Default: — Context: location Syntax: root path; Default: root html ...
- 你真的了解nginx重定向URI?-rewrite和alias指令
未经允许不得转载!最近发现有博主转载我的文章,并没有跟我打招呼,也没有注明出处!!!! 熟悉Nginx的同学都知道Nginx可以用来做负载均衡和反向代理,非常好用.做前后端分离也是非常的方便. 今天我 ...
- nginx配置中root与alias的区别
nginx指定文件路径有两种方式root和alias,这两者的用法区别,使用方法总结了下,方便大家在应用过程中,快速响应.root与alias主要区别在于nginx如何解释location后面的uri ...
- nginx配置中root和alias的区别
例:访问http://127.0.0.1/download/*这个目录时候让他去/opt/app/code这个目录找. 方法一(使用root关键字): location / { root /usr/s ...
- nginx location关于root、alias配置的区别
一.首先优先级如下: = 表示精确匹配,优先级最高 ^~ 表示uri以某个常规字符串开头,用于匹配url路径(而且不对url做编码处理,例如请求/static/20%/aa,可以被规则^~ /stat ...
- Nginx Location模块
相关知识点:URI:统一资源标识符,是一个用于标识某一互联网资源名称的字符串,该种标识允许用户对任何的资源通过特定的协议进行交互操作.URL:统一资源定位符,由三部分组成(1)http://协议 (2 ...
- Nginx Location规则
Nginx由内核和模块组成,其中内核的设计非常微小和简洁,完成的工作也非常简单,仅仅通过查找配置文件将客户端的请求映射到一个location block,而location是Nginx配置中的一个指令 ...
- nginx的location、root、alias指令用法和区别
nginx指定文件路径有两种方式root和alias,指令的使用方法和作用域: [root] 语法:root path 默认值:root html 配置段:http.server.location.i ...
- nginx的location root alias指令以及区别
原文:http://blog.csdn.net/bjash/article/details/8596538 location /img/ { alias /var/www/image/; } #若按照 ...
随机推荐
- JSP的部分知识(二)
指令include和动作include的区别 通过之前的学习知道,JSP最后会被转译成Servlet如果是指令include <%@include file="footer.jsp&q ...
- 批处理cmd开启,关闭防火墙
管理员启动dos窗口 开启防火墙: netsh advfirewall set allprofiles state on 关闭防火墙: netsh advfirewall set allprofile ...
- Arm-Linux 移植 jpeg库
背景: jpeg库的使用可以提高显示效率. host平台 :Ubuntu 16.04 arm平台 : S5P6818 jpeg :v9c arm-gcc :4.8.1 主机准备: 运行以下脚 ...
- hdu 6661 Acesrc and String Theory (后缀数组)
大意: 求重复$k$次的子串个数 枚举重复长度$i$, 把整个串分为$n/i$块, 如果每块可以$O(1)$计算, 那么最终复杂度就为$O(nlogn)$ 有个结论是: 以$j$开头的子串重复次数最大 ...
- .NET Framework 4安装问题
1.安装时,系统提示:运行此安装程序之前,必须安装 32 位 Windows 映像处理组件(WIC). http://www.microsoft.com/downloads/zh-cn/details ...
- mybatis获取刚刚插入到数据库的数据的id(转载)
原文地址:https://blog.csdn.net/hehuihh/article/details/82800739 我用的是第一种写法,直接把代码copy到insert标签里(id要是自增id) ...
- springboot_4 spring boot 使用servlet,filter,listener和interceptor
上一篇我们学习了 spring boot 利用Controller响应数据与响应页面. 一般的Web开发使用 Controller 基本上可以完成大部分需求,但是有的时候我们还是会用到 Servlet ...
- iOS 动画基础-显式动画
摘要 显式动画 属性动画 CABasicAnimation *animation = [CABasicAnimation animation]; [self updateHandsAn ...
- 【前端开发】】js中var写和不写的区别
js中var用与不用的区别 Javascript声明变量的时候,虽然用var关键字声明和不用关键字声明,很多时候运行并没有问题,但是这两种方式还是有区别的.可以正常运行的代码并不代表是合适的代码. v ...
- RocketMQ问题
RocketMQ原理(4)——消息ACK机制及消费进度管理 RocketMQ消费者,设置setConsumeFromWhere无效的问题 MQ的CONSUME_FROM_LAST_OFFSET未生效 ...