繁体   English   中英

将 angular 9 应用程序部署到 Jboss 7 将 URL 重写为 index.html

[英]Deploying angular 9 app to Jboss 7 rewrite URL to index.html

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

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

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

在 Panagiotis Chavariotis 评论的帮助下(使用这篇文章),我通过添加这个配置文件 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('/');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM