Rules when in a virtual directory

Topics: User Forum
Sep 14, 2009 at 2:02 PM


I am working on a site that has the ability to be both a root application and inside a virtual directory. I have rules like:-

RewriteRule /Posts/(.*)/January/$ /Posts.aspx?year=$1&part=1 [I]

These of course work for the root but don't even seem to be picked up by the virtual directory. I therefore tried:-

RewriteRule (.*)/Posts/(.*)/January/$ (.*)/Posts.aspx?year=$2&part=1 [I]

Which broke both.

Can someone please point me in the right direction.


Sep 14, 2009 at 7:22 PM

Rules are made of regular expressions, and then replacement strings and options.  The order of the rules also matters.  If you're having trouble with the regex, You can try some nice free Regex tools, like Expresso, RegexDesigner from Rad Softwware, or Gerry Shaw's tool, to get the basic regex developed. But you have to remember that different regex engines work differently and as far as I know these engines all use .NET, which is different from the PCRE used by IIRF.  This matters only when you use advanced features in PCRE that are not supported by .NET, or vice versa.

After you get the regex you need, there's a really handy tool included with IIRF called the TestDriver, that helps you debug your rules to make sure they work for all the URLs you expect.

Sep 15, 2009 at 7:45 AM

Hi Cheeso,

Actually I think my problem is that the ISAPI fiter isn't working when used on a Virtual Directory. The logs are showing nothing. That's where I'm looking for help.



Sep 15, 2009 at 8:01 AM

Never mind! Fresh head.

I thought the fact that the virtual directory pointed to the application with the ISAPI Filter was enough. It's not. It has to be applied to the site containing the virual directory as well.