IIS7 / Tomcat 6

Topics: Developer Forum, User Forum
Nov 3, 2009 at 2:07 PM

Disclaimer: I'm a complete novice at url rewriting / regex.  

I'm having an issue with this setup: IIS7/Tomcat 6 / IIRF 1.2.16.

I've set up a rule to rewrite this:  mydomain.com/news/bobblahblah
to this: mydomain.com/index.cfm?section=news&page=bobblahblah

I'm receiving a 404 error from Tomcat:  HTTP Status 404 - /news/bobblahblah

Here is the rule from my INI file:

RewriteRule ^([\w]+)/([\w]+)   /index.cfm?section=$1&page=$2


So, from what I understand, it seems to be processing the rewrite in IIS(since it is sending it to Tomcat), but why is Tomcat trying to process it as /news/bobblahblah?  What am I missing?

Coordinator
Nov 4, 2009 at 9:57 AM

It doesn't look like your rule is firing.  I suggest that maybe you need a leading slash on the pattern.  ^/(etc etc...  rather than ^(... 

The slash is always present in IIS URLs, so if you begin your pattern with ^, denoting the beginning-of-line, then the very next character is going to be / .   

I'll say it a different way:  If you have a ^ as the first character, then you should follow it with / if you want your pattern to match.

Hint:  check out the IIRF Log file - it will tell you whether a rule has matched or not, for a given URL request.

ALSO: there's a really nifty command-line tool called TestDriver that lets you test your rules against incoming URLs.  It would have shown you very clearly that your rule did not match.

Good luck!