【问题标题】:Deploying angular 9 app to Jboss 7 rewrite URL to index.html将 Angular 9 应用程序部署到 Jboss 7 将 URL 重写为 index.html
【发布时间】:2021-01-14 23:54:02
【问题描述】:

我正在尝试将 Angular 应用程序战争文件部署到 jboss 7。但是,我遇到了一个问题; 404 page not found 刷新页面时在生产版本中。我知道所有 Angular 路由都应该通过 index.html 文件提供,所以我必须重写 URL。我在tomcat中尝试过,它使用

RewriteCond %{REQUEST_PATH} !-f
RewriteRule ^/dashboard/(.*) /dashboard/index.html

但我不知道如何用 jboss 7 做同样的事情。

【问题讨论】:

标签: angular jboss7.x


【解决方案1】:

在Panagiotis Chavariotis评论的帮助下(使用这个post),我通过添加这个配置文件WEB-INF/undertow-handlers.conf解决了这个问题:

path-prefix('/assets') -> done;
regex('(.*).js') -> done;
regex('(.*).ttf') -> done;
regex('(.*).woff') -> done;
regex('(.*).woff2') -> done;
regex('(.*).jpg') -> done;
regex('(.*).png') -> done;
regex('(.*).css') -> done;
regex('(.*).html') -> done;
path-prefix('/') -> rewrite('/');

【讨论】:

  • 我不明白为什么这意味着:对于每个请求都会提供 index.html。有人可以解释一下吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-17
  • 2018-09-06
相关资源
最近更新 更多