Nginx配置静态文件404问题解决
星期一, 2017-10-23 | Author: Lee | computer, linux | 4,014 views
Nginx提供了另外一个静态路径配置 : alias
alias与root区别
官方root
Sets the root directory for requests. For example, with the following configuration location /i/ { root /data/w3; } The /data/w3/i/top.gif file will be sent in response to the “/i/top.gif” request |
官方alias
Defines a replacement for the specified location. For example, with the following configuration location /i/ { alias /data/w3/images/; } on request of “/i/top.gif”, the file /data/w3/images/top.gif will be sent. |
当访问/i/top.gif时,
root是去/data/w3/i/top.gif请求文件,
alias是去/data/w3/images/top.gif请求
root响应的路径:配置的路径+完整访问路径(完整的location配置路径+静态文件)
alias响应的路径:配置路径+静态文件(去除location中配置的路径)
修改配置为
location /api/v1/upload { alias /home/v1/upload/; } |
注意
使用alias时目录名后面一定要加“/”
一般情况下,在location /中配置root,在location /other中配置alias
文章作者: Lee
本文地址: https://www.pomelolee.com/1769.html
除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址
No comments yet.
Leave a comment
Search
相关文章
热门文章
最新文章
文章分类
- ajax (10)
- algorithm-learn (3)
- Android (6)
- as (3)
- computer (85)
- Database (30)
- disucz (4)
- enterprise (1)
- erlang (2)
- flash (5)
- golang (3)
- html5 (18)
- ios (4)
- JAVA-and-J2EE (186)
- linux (143)
- mac (10)
- movie-music (11)
- pagemaker (36)
- php (50)
- spring-boot (2)
- Synology群晖 (2)
- Uncategorized (6)
- unity (1)
- webgame (15)
- wordpress (33)
- work-other (2)
- 低代码 (1)
- 体味生活 (40)
- 前端 (21)
- 大数据 (8)
- 游戏开发 (9)
- 爱上海 (19)
- 读书 (4)
- 软件 (3)