1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > Nginx.conf配置文件中alias与root的区别

Nginx.conf配置文件中alias与root的区别

时间:2023-02-03 09:21:33

相关推荐

Nginx.conf配置文件中alias与root的区别

他们都可以用来指定请求资源的路径

root:

location /wap/ {root /wap_web/static;}

假设访问的是http://localhost:8080/wap/test.html

那它实际访问的资源路径是:wap_web/static/wap/test.html

alias:

location /wap/ {alias /wap_web/static/; }

实际访问的资源路径是:/wap_web/static/test.html

alias指定的路径是location的别名,不管location的值怎么写,资源的 真实路径都是 alias 指定的路径

alias 只能作用在location中,而root可以存在server、http和location中。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。