Pandemonium in Piscataway

Imagine your life as a radio play by play guy in a small college town where the football team is 1-12. You love football, and you love your school, but hardly anyone listens to your broadcasts. You don’t care, you love your job.

Tonight your team is 8-0, and ranked 15th in the country, and plays the 3rd ranked team. This is the biggest football game in the 137 years football has been played at your school. You are trying to figure out what you say if your Scarlet Knights win. You know lots and lots of people will be listening.

Sure enough, Rutgers beats Louisville in an instant classic, winning 28-25 on a field goal with 13 seconds left on the clock.

You say, “There’s pandemonium in Piscataway!”.

Classic.

This is why I love college sports.

Tomcat, Apache mod_jk and mod_rewrite

I have some tomcat apps with apache 2 in front of them, using mod_jk. Works great. I decided I wanted to use mod_rewrite (shudder) to make some friendlier URL’s, you know instead of /some/path/command?var=value, have /some/path/command/value. Sounds great. Couldn’t get it to work for anything. Found a howto at the Helma site, which had some good info, but he left out one very important thing.

Say I have a rule like:

RewriteRule ^(.*)/command/(.*)$ $1/command?var=$2 [QSA]

This is a basic rewrite to make friendlier URLS like I wanted. The QSA option allows me to muddle with the query string in my rule. When I use this rule, httpd doesn’t do what I want it to. It rewrites the URL, then prepends the directory on disk that this container (apache VirtualHost or Directory keywords) points to. I want it to get processed by mod_jk instead.

After a few minutes I discovered the “PT” option. So if I change my rule to be:

RewriteRule ^(.*)/command/(.*)$ $1/command?var=$2 [PT,QSA]

the rewritten URL will be passed through to other handlers, like mod_jk.

Happiness. Finally.