简体   繁体   English

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

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

I'm trying to deploy an angular app war file to jboss 7. But, I'm facing a problem;我正在尝试将 angular app war 文件部署到 jboss 7。但是,我遇到了一个问题; 404 page not found in production build when refresh a page.刷新页面时,在生产版本中404 page not found页面。 I know that all Angular routes should be served via the index.html file So I must do an URL rewrite.我知道所有 Angular 路由都应该通过 index.html 文件提供,所以我必须重写 URL。 I tried it in tomcat and it worked using我在 tomcat 中尝试过,它使用

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

But I doesn't know how to do the same thing with jboss 7.但我不知道如何用 jboss 7 做同样的事情。

By the help of Panagiotis Chavariotis comment (using this post ), I resolved the problem by adding this configuration file WEB-INF/undertow-handlers.conf:在 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