title: 404 Error when reload page in a Tomcat web application
body: <p>I've deployed a Java web application using spark-java and angularJS (ui-router) on a Tomcat9 web server. When I try to reload the page, tomcat will launch an <code>HTTP Status 404</code>. This happens with all the views except for the main route '/'.
  Tomcat is mapped on port 80, started by root user, and the app has been deployed on webapps/ROOT folder. I don't really know what to do.</p>
  
  <p>I also use html5mode in app.js: </p>
  
  <pre><code>app.config(["$locationProvider", function($locationProvider) { 
       $locationProvider.html5Mode(true); 
  }]);
  </code></pre>
  
  <p>and added <code>&lt;base href="/"&gt;</code> in <code>index.html</code> <code>&lt;head&gt;</code></p>
  
  <p>UPDATE:</p>
  
  <p>In my server.xml I added the following code:</p>
  
  <pre><code>&lt;Host name="localhost"  appBase="webapps"
              unpackWARs="true" autoDeploy="true"&gt;
      &lt;Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/&gt;
  &lt;/Host&gt;
  </code></pre>
  
  <p>and in /conf/Catalina/localhost/rewrite.config:</p>
  
  <pre><code>RewriteRule ^/(.*) index.html [L]
  </code></pre>
  
  <p>And now i've this console error for all the imported scripts:</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token &lt;
  </code></pre>
  
  <p>It looks like it replaces all the scripts with <code>index.html</code> text.</p>