You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Michael Percy <mp...@portera.com> on 2000/09/07 22:45:37 UTC

FW: Solution (kindof) - mod_rewrite not working

Some developer who knows what they are doing, please look this over. I have
heard troubles concerning Tomcat breaking Apache mod_rewrite from many
people, using every recent version of Tomcat from 3.1 to 3.2b3.

Thank you.
Michael Percy

-----Original Message-----
From: Mike Bremford [mailto:mikeb@paperx.com]
Sent: Thursday, September 07, 2000 12:13 PM
To: tomcat-user@jakarta.apache.org
Cc: Matt (E-mail)
Subject: Solution (kindof) - mod_rewrite not working


Hi guys - can someone who's also signed up to tomcat-dev forward this on to
that list?


There's been a long standing problem when using Apache+mod_rewrite with
tomcat - Tomcat always seemed to pick up the URL before it was rewritten,
not after.

Anyway, the following change to Ajp12ConnectionHandler.java worked for me. I
won't send a patch, as it's a single line that needs changing - the one
listed below starting with "requestURI". Previously this string was assigned
to "dummy", which was a shame as it contained the rewritten URI. If rewrite
isn't used, it contains the same value as the original URI requested.

I have no idea if this is 100% correct or if it will cause problems further
down the line or in a different area, but it works for me. Please consider
including it, or something like it, in the next 3.2 beta, as this has popped
up a lot on the tomcat-user mailing list, and it's been doing my head in for
weeks :-)

If any brave souls who have staked their site on mod_rewrite only to find it
didn't work (like me!) want to take a chance, I've build a jar file and put
it online at http://big.faceless.org/webserver.jar. This is basically a
stock 3.2b3 webserver.jar file with this single line changed - overwrite the
file in /usr/local/jakarta-tomcat/lib with this. Obviously there's a
significant chance that I messed up big time, so use at your own risk.


Note this doesn't conflict with the patch sent in 2000-09-06 by
jean-paul_abgrall@phoenix.com (BugRat #64) - I tried that one first, it
didn't fix our problem.

The version I'm using is 3.2b3. Here's the change.


// XXX don't set lookup path - problems with URL rewriting.
// need to be fixed.
//          if(contextPath!=null && contextPath.length() >0 )
//              lookupPath=requestURI.substring( contextPath.length() + 1 );
if( doLog ) log("AJP: URI: " + requestURI + " CP:" + contextPath + " LP: " +
lookupPath);
dummy = ajpin.readString(null);                   //script filename
//          System.out.println("AJP: Script filen=" + dummy);

requestURI = ajpin.readString(null);                   //script name  <<<<<
CHANGED LINE
//          System.out.println("AJP: Script name=" + dummy);



Hope someone finds it useful. Please let me know if I've cocked it up
somehow, as it's going into production in a couple of weeks come hell or
high water.



Cheers... Mike