希望实现的效果是,用户只要访问域名,自动跳转到index.html页面
原本配置为:
location / {
root /users/apple/git_local/YAE/YAE/frontend;
index /portal/nail/index.html;
}
这样虽然可以达到目的,但是浏览器里的URL还是www.xxx.com。如果页面上有链接使用相对路径,就会发生404错误,所以需要配置为:
- rewrite ^/(index.html)?$ portal/nail/index.html redirect;
- location / {
- root /users/apple/git_local/YAE/YAE/frontend;
- index /portal/nail/index.html;
- }
rewrite ^/(index.html)?$ portal/nail/index.html redirect;
location / {
root /users/apple/git_local/YAE/YAE/frontend;
index /portal/nail/index.html;
}
浏览器的URL会变成www.xxx.com/portal/nail/index.html,这样相对路径就能正常访问了
评论