I have got the tomcat 8 rewrite to work but seems to missing something in rewrite.config that is causing the last condition to not execute. For benefit of others, i have the RewriteValve to work for my specific application and not globally. What works for me is given below.
In my app's META-INF context.xml file i have included below line
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" asyncSupported="true"/>
In my app's WEB-INF, i have a rewrite.config file that says below things after incorporating the feedback seen in the other tomcat 8 rewrite thread, regarding issue with using {REQUEST_FILENAME} being null. I have not used the REQUEST_FILENAME and my config looks like below.
RewriteCond %{REQUEST_URI} .*\.(css|js|html|png|jpg|jpeg|gif|txt|ico) [OR]
RewriteCond %{REQUEST_URI} ^\/api\/ [OR]
RewriteRule ^(.*)$ -
RewriteRule ^(.*)$ /index.html
Now if URI is a js,css etc or if the URI starts with /api/ i see the rewrite rule is being evaluated and no substitution is being done. i.e below urls seem to work ok and no substitution is being done. localhost:8080/api/abc/xyz , localhost:8080/css/abc.min.css
But for some reason the last rule is not getting hit at all even when the URI has a valid one to get hit by it.For ex. URL like localhost:8080/def/ghi should have got redirected to index.html, but it seem to not getting rewritten. I am not sure what am i missing in the rewrite.config causing this behavior. I could move to a ! condition to do the rewrite too, but just want to get my understanding clear when i use Mulitple RewriteRule combination.
Any help is appreciated.