nginx中root和alias的区别
来源:互联网 发布:95579交易软件下载 编辑:程序博客网 时间:2024/05/18 02:42
nginx中root和alias的区别
今天使用nginx搭建了一个网站,访问后出现404错误Not found. 上网查了一下原因,是由于nginx的配置不对。因为我是有两个web目录,这两个目录在不同的位置上。而且我不想把两个目录合并在一起,所以就要配置两个location。配置如下:
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { root /www; # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /website/ { root /var/lib/www; autoindex on; }}
上面的配置浏览http://localhost/website/会显示404错误,因为root属性指定的值是要加入到最终路径的,所以访问的位置变成了/var/lib/www/website/
。而我不想把访问的URI加入到路径中。所以就需要使用alias属性,其会抛弃URI,直接访问alias指定的位置, 所以最终路径变成/var/lib/www/
。(最后需要加斜线)
location /website/ { alias /var/lib/www; autoindex on; }
@完
参考:http://blog.csdn.net/u011510825/article/details/50531864
阅读全文
0 0
- nginx中root和alias的区别
- nginx中root和alias的区别
- nginx中alias和root区别
- nginx中location的root和alias用法区别
- nginx的root 和 alias的区别
- nginx alias和root的区别
- nginx配置root和alias的区别
- nginx location的root和alias区别
- nginx配置alias和root的区别
- nginx alias和root 区别
- nginx的root和alias指令的区别
- nginx的root和alias指令的区别
- nginx的root和alias指令的区别
- nginx的root和alias指令的区别
- nginx的root和alias指令的区别
- nginx配置文件中的root和alias的区别
- nginx的location、root、alias指令用法和区别
- nginx root alias 区别
- string、char*、CString之间的转换
- Lintcode 上一个排列
- opencv 霍夫变换检测圆环
- word实现文献引用2
- Sampled Softmax 论文笔记:On Using Very Large Target Vocabulary for Neural Machine Translation
- nginx中root和alias的区别
- spring data jps
- CRC校验程序设计
- React-Native 常见问题总结
- 909422229_JSON数组与JSON对象的创建使用
- Eclipse4.4.2+scala2.11+jdk1.8+scala-plugin开发第一个scala程序
- 解决Spring MVC @ResponseBody返回中文字符串乱码问题
- spark 2.1 RDD compute process
- 获取当前日期时间字符串的方法