Click to See Complete Forum and Search --> : [RESOLVED] Apache mod rewrite question on proxy


trepidity
09-28-2007, 08:09 PM
I am trying to do a simple rewrite of URLs in an Apache2 virtual host that proxies to tomcat. I want the URL rewritten internally(i.e. so the user-agent can't see) so that "http://www.mydomain.com/servlets/comments/12345.jpg" becomes instead "http://www.mydomain.com/servlets/hello.do?12345"

It basically recieves a fake file name "*.jpg" and redirects it to my servlet with the filename without extension in the query string like "hello.do?*"

Here is what I have in the apache virtual host .conf file to do this:

RewriteEngine On
RewriteRule ^/servlets/comments/[(0-9)+]\.jpg$ /servlets/hello.do?$1 [PT]

<Proxy *>
Allow from all
</Proxy>

ProxyPass / http://localhost:8080/myfolder/
ProxyPassReverse / http://localhost:8080/myfolder/


Apache doesn't seem to wanna follow the rule, it just proxys through like it wasn't there. Whats going on here? Thanks so much.

trepidity
09-28-2007, 08:59 PM
Lol i got it. Seems when I was writing the Regex expression in the rewrite rule I was referencing from a site that had the [ and ( characters reversed in meaning. The fix would be this:

RewriteRule ^/servlets/comments/([0-9]+)\.jpg$ /servlets/hello.do?$1 [PT]