1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > nginx中配置location的root(alias)访问同一个地址文件

nginx中配置location的root(alias)访问同一个地址文件

时间:2019-06-09 00:21:46

相关推荐

nginx中配置location的root(alias)访问同一个地址文件

我要访问/B/c.html 按照正常的location配置应该是这样的:

location / {

root /data/html;

index index.html index.htm;

}

以上配置说明我需要在/data/html/B/目录下访问c.html

但是途中遇到个问题,我需要重新做个测试网站,不能影响原来的目录结构。那么我就可以直接使用虚拟目录的配置进行访问。比如说访问/test/B/c.html地址,可以按照如下配置:

location /test/ {

alias /data/html/;

index index.html index.htm;

}

按照/test/B/c.html地址访问,其实还是访问的是/data/html/B/目录下的c.html页面

工作实际运用,在原有的网站下加两个静态站点:

location /new/ {alias /var/www/new/;try_files $uri $uri/ /new/index.html;}location /dc/ {alias /var/www/dc/h5/dist/;try_files $uri $uri/ /dc/index.html;}

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