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
SimpleUrlHandlerMapping.  

A concrete example.  We used to serve a 302 response for /crate, so the
client is redirected to a subsequent request for
/donors/redeem_gift_certificate.html?partner=CRATEANDBARREL&utm_campaign
=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
/donors/redeem_gift_certificate.html?partner=CRATEANDBARREL&utm_campaign
=CBGC [NC,PT]

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

  JkMount /* worker1

First, note that requests to http://www.myserver.com/
donors/redeem_gift_certificate.html?partner=CRATEANDBARREL&utm_campaign=
CBGC work correctly.

However, if I load http://www.myserver.com/crate 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.

Thanks,
David Crane
dav...@donorschoose.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to