tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Crane" <>
Subject Combining Apache RewriteRule and JkMount to pass through to Tomcat
Date Fri, 26 Jun 2009 18:47:15 GMT
I am having difficulty using the internal redirect capabilities of
Apache mod_rewrite and passing through requests to Tomcat through
mod_jk.  We are using Apache/2.2.3 and Tomcat/6.0.16.  Our tomcat war
application is based on SpringFramework 2.5.4, configured with a

A concrete example.  We used to serve a 302 response for /crate, so the
client is redirected to a subsequent request for
=CBGC.  Now we want our Apache/Tomcat to serve up the content for the
longer URL directly when the short /crate HTTP request arrives.  I keep
getting a 404 error instead.

This is the mod_rewrite directive:

  RewriteRule /crate

I also have this mod_jk directive, which would act on either version of
the URL:

  JkMount /* worker1

First, note that requests to
CBGC work correctly.

However, if I load in a browser, I am
getting a 404 error back from Tomcat and Apache.  It appears that Tomcat
is being passed a mixed-up URL of
"/crate?partner=CRATEANDBARREL&utm_campaign=CBGC".  Our Tomcat
application doesn't have an SimpleUrlHandlerMapping entry for /crate,
but it does for /donors/redeem_gift_certificate.html.  I tested and
found that the HttpServletRequest returns "/crate" for
request.getRequestURI(), but "partner=CRATEANDBARREL&utm_campaign=CBGC"
for request.getQueryString().

Note that I do have the PT flag for the RewriteRule, as others have
advised.  I get the same results by reversing the order of the
RewriteRule and JkMount directives.

This is part of an SEO effort, in which we are trying to persist these
URLs as they were originally requested, rather than do 301/302 redirects
back to the browser or crawler.  So I suspect someone else has figured
this out.

David Crane

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message