博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx中使用root和alias映射静态文件路径的区别
阅读量:3908 次
发布时间:2019-05-23

本文共 489 字,大约阅读时间需要 1 分钟。

连接linux服务器,然后在已有安装的nginx目录下面,创建一个static目录用来演示测试,然后创建一个a.html和b.html文件

location /test {

         root /usr/bin/nginx1.10.0/static;

}

访问地址为:host/test/a.html-->文件目录:/usr/bin/nginx1.10.0/static/test/a.html     访问失败,因为a.html不在test目录下,而在static目录下。可以在static目录下面创建一个test目录,并将a.html移动到该目录下面,此时就可以访问成功

location /test {

         alias /usr/bin/nginx1.10.0/static/;

 }

访问地址为:host/test/b.html-->文件目录:/usr/bin/nginx1.10.0/static/b.html       访问成功

说明root把匹配的字符/test拼接到了文件路径中,而alias没有

 

注意:

       继续测试还可以发现root方式后面的路径/斜杠加与不加都一样,但alias最后必须要有斜杠

转载地址:http://kcqen.baihongyu.com/

你可能感兴趣的文章
BFS (Level Order Traversal)
查看>>
Binary Tree Summary
查看>>
Minimum Depth of a Binary Tree
查看>>
python wsgi web server gateway interface
查看>>
cgi, wsgi
查看>>
Restful Web Service
查看>>
REST and SOAP
查看>>
Web Browse Process
查看>>
Web Progress
查看>>
Hash
查看>>
Hash in Python
查看>>
取模运算和求余运算的区别
查看>>
Modulo and Reminder
查看>>
Round robin
查看>>
consistent hashing
查看>>
Inverted Index
查看>>
Crawler
查看>>
Bloom Filter
查看>>
Dynamic Programming
查看>>
Python Singleton
查看>>