我要访问http://yuming.com/B/c.html 按照正常的location配置应该是这样的:
location / {
root /data/html;
index index.html index.htm;
}
以上配置说明我需要在/data/html/B/目录下访问c.html
但是途中遇到个问题,我需要重新做个测试网站,不能影响原来的目录结构。那么我就可以直接使用虚拟目录的配置进行访问。比如说访问http://yuming.com/test/B/c.html地址,可以按照如下配置:
location /test/ {
alias /data/html/;
index index.html index.htm;
}
按照http://yuming.com/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;
}