5

Below is the issue that I am facing and needs some help.

Initial problem:

I have a tomcat server where I have deployed three angular projects (inside the web apps folder). When I start the Tomcat server, the angular apps come up. Once I login to the APP and navigate through the pages and then try to refresh any page inside the angular app it gives me a 404 error.

The solution to the initial problem:

I got a solution to resolve the above issue as given below:

  1. adding the below parameter to the "server.xml" file inside the Tomcat config folder. Parameter:-

  2. I created a rewrite.config file inside the /config/Catalina/localhost/ folder and wrote rewrite rules for all the 3 angular apps.

New Problem:

Only one of the Angular APP is coming up but all the other application's index.html pages are not loading and in the logs I can see 304 error.

Questions: Can someone please suggest how to write multiple rewrite configs for the different angular project in the same tomcat rewrite.config file.

More Details: Angular apps are in the location:

Tomcat path/webapps/app1 Tomcat path/webapps/app2 Tomcat path/webapps/app3

rewrite.config file content:

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

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

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

Only app1 is loading but app2 and app3 index.html pages are not loading and tomcat logs have 304 for app2 and app3.

Please suggest how to write the rewrite rules for multiple angular applications.

1 Answers1

0

Are you sure that just first one and not just third one is served correctly in your case? Because I think you are missing RewriteRule flag [L] ...last rule:

RewriteCond %{REQUEST_PATH} !-f
RewriteRule ^/app1/(.*) /app1/index.html [L]

RewriteCond %{REQUEST_PATH} !-f
RewriteRule ^/app2/(.*) /app2/index.html [L]

RewriteCond %{REQUEST_PATH} !-f
RewriteRule ^/app3/(.*) /app3/index.html [L]
sasynkamil
  • 859
  • 2
  • 12
  • 23