1
votes

I have deployed my angular 5 apps on tomcat. The deep link routing like (localhost:8080/emp/1) works fine but direct link routing like(localhost:8080/aboutUs) doesn't work.

It throws a 404.

I am creating my build and copying all the files from dist folder to the tomcat webapps/root folder and created a .htaccess file mentioned under https://angular.io/guide/deployment.

1
Have you set it up in tomcat so that it redirects 404 error to index.html as well? - Kelvin Lai
Yes , I have created a .htaccess file under root folder and added the below in the same -<ifmodule mod_rewrite.c=""> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </ifmodule> Do i need to add anything else ? - Ajitesh
Did you deploy with "ng build --prod " or "ng build" ? - Mohammad Daliri
ng build --prod - Ajitesh

1 Answers

0
votes

Shouldn't use href. I was using <a href for direct links and <a router link for deep links. Once I changed every link to <a routerLink everything works.