title: Error 404 with Angular 4 using routing on Tomcat 9 with Valve
body: <p>I'll tell you what happens by following steps:</p>
  
  <p>1) I have my app project based on Angular 4.0.2. I'm using routing. These are my routes in app.module.ts:</p>
  
  <pre><code>const routes: Routes =
  [
  { path: '', component: LoginComponent },
  { path: 'dashboard',  component: DashboardComponent }, 
  { path: 'login',  component: LoginComponent }
  ];
  </code></pre>
  
  <p>So the first screen of the web application is Login.</p>
  
  <p>2) I executed the command ng build -prod</p>
  
  <p>3) I move the folder dist into Tomcat webapps folder</p>
  
  <p>4) I modified the file index.html changing base href. Now it's  </p>
  
  <p>5) In /Tomcat9/conf/context.xml, I added the following instruction:</p>
  
  <pre><code>&lt;Valve className="org.apache.catalina.valves.rewrite.RewriteValve" /&gt;
  </code></pre>
  
  <p>6) I created the folder WEB-INF, then I created the file rewrite.config, this file contains:
       # If an existing asset or directory is requested go to it as it is</p>
  
  <pre><code>RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
  RewriteRule ^ - [L]
  
  # If the requested resource doesn't exist, use index.html
  RewriteRule ^ /index.html
  </code></pre>
  
  <p>7) I started Tomcat server</p>
  
  <p>8) Next I openned a Mozilla browser and I put in address bar 
      localhost:8080/dist/
  It appears the login screen with 2 textboxes (user and pass) and one button for login.</p>
  
  <p>9)When I press the button with user and pass valid. it goes to dashboard screen and I see the address bar changes to:
  localhost:8080/dist/dashboard.</p>
  
  <p>10) After that, I go to address bar and I wrote manually: localhost:8080/dist/dashboard. </p>
  
  <p>Then I press Enter and it appears Error 404.</p>
  
  <p>It should keep showing dashboard screen and not Error 404.</p>
  
  <p>This app works well in Apache server with .htaccess, but not in Tomcat 9</p>
  
  <p>Why is not showing dashboard screen in this case if I configured the rewrite.config? what is missing in order to avoid error 404?</p>