There really is a dearth of documentation on IIS6's wildcard redirection. It seemed simple - I was renaming the Blog.aspx page in my blog to BlogEntry.aspx (no, don't ask why) and I wanted all the requests for the old page to go to the new one. Similarly, I wanted requests for the Rss2.aspx page to go to the Rss.aspx page. (Don't ask about this either.) Except IIS's wildcards don't work the way you expect, and the expected redirection rules led to either: - No rewriting,
- Incorrect rewriting, or
- Really, really incorrect rewriting that kept rewriting until the URL was too long for it to deal with.
So, a frustrating half-hour later, after trying every interpretation of the two documents Microsoft provides I could think of, I've come up with a rewriting rule that works. And I'm going to share it with you now. Remember, this is a fairly trivial thing to redirect (confused a little by the way my blog puts querystring parameters in the path, I admit). And yet this is the most complex example of IIS URL rewriting I've seen. The examples in the documentation and the ones I've found elsewhere are much more trivial (something I didn't think would be possible). Are you ready? Here goes: *;/*Rss2.aspx;/Blog/Rss.aspx;/*/Blog.aspx;/Blog/$0/BlogEntry.aspx That does the trick, for me at least. I really figured something like: *;Rss2.aspx;Rss.aspx;*/Blog.aspx;$0/BlogEntry.aspx would have worked...
Categories: .NET Permalink #.Posted by 'geoff' on Thursday, 03 April 2008 at 5:49PM
|