简体   繁体   中英

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; 404 page not found in production build when refresh a page. I know that all Angular routes should be served via the index.html file So I must do an URL rewrite. I tried it in tomcat and it worked using

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

But I doesn't know how to do the same thing with 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:

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('/');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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