location /haha {
alias /opt/projects/testStatic;
try_files $uri $uri/ @router;
index index.html;
}
# 处理直接访问VUE工程中的某个子页面
# 对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
# 因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
# 配置静态工程资源路径
location /static {
root /opt/projects/testStatic;
}
网友评论