I have Apache running in a domain, for example http:// example.com. I also have Tomcat running on my server and I've forwarded all requests made to http:// example.com/t/ to Tomcat and all other URLs are served by Apache directly.
My problem is I have a URL like http:// example.com/bar, but I want tomcat to process that url, so it should actually point to http:// example.com/t/bar. In other words, the URL should be processed by Tomcat which gets the application context "bar".
Problem is, I'm not quite sure how to make the proper rewrite rule for this. I tried adding this to sites-available/default
RewriteEngine on RewriteRule ^/bar(.*) /t/bar$1 [R]
But that doesn't preserve the URL, and instead just redirects to the Tomcat URL with the /t/ prefix. If I remove the [R], then I just get a 404.
What is the proper RewriteRule to solve my problem?