title: Tomcat 8 URL Rewrite
body: <p>I have an AngularJS webapp and Jersey backend. I need to setup URL rewriting, so everything except given exceptions will be rewritten to Angular's index.html.</p>
  
  <p>Eg.:</p>
  
  <pre><code>http://my.domain.com/about will be rewritten
  http://my.domain.com/photos/photo1.jpg will NOT be rewritten (file photo 1 exists)
  http://my.domain.com/rest/myservice will be NOT be rewritten (it is a call to REST service)
  </code></pre>
  
  <p>I have set up the Tomcat 8 URL Rewrite Valve as follows:</p>
  
  <p>in <strong>conf/server.xml</strong></p>
  
  <pre><code>&lt;Host name="my.domain.com" appBase="webapps/MyDomainServer" unpackWARs="true"
             autoDeploy="true"
             xmlValidation="false" xmlNamespaceAware="false"&gt;
    &lt;Valve className="org.apache.catalina.valves.rewrite.RewriteValve" /&gt;
    &lt;!-- access logging, aliases,...--&gt;
  &lt;/Host&gt;
  </code></pre>
  
  <p>in <strong>conf/Catalina/my.domain.com/rewrite.config</strong></p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d [OR]
  RewriteCond %{REQUEST_FILENAME} ^/rest.*
  RewriteRule ^ - [L]
  
  RewriteRule ^ index.html [L]
  </code></pre>
  
  <p>Tomcat ignores my rewrite settings, nothing is rewritten, no error/exception is in the log. What am I doing wrong? Thanks in advance.</p>
  
  <p>I have tried to move RewriteValve to config.xml in META-INF and rewrite config to WEB-INF, but it behaved in the same way.</p>