Using ISAPI_Rewrite to fine tune URL re-writing

Jack Simpson

Head of Marketing and Communications

So it goes

I finally feel like I can go to bed with the website ready to face the world.  The last big hurdle is the multiple hostnames we own that we would like associating with the main website  Most notably, and, both of which we own currently.  Although I could just add them as portal aliases they would then be indexed separately by search engines (e.g. Google), to the detriment of the site ranking.  Instead it’s necessary to issue a 301 redirect (permanent redirect) when  navigating to a page on a ‘holding URL’.

This is especially important as our hostname has always historically been  Last year I made the decision to use the longer, but more ‘guessable’, which we’ve since marketed heavily.  Unfortunately, all our rankings are based on the old URL, 301 redirects can sort that out.

A second issue I had was with our heavily publicised RSS Feed.  Obviously, it would be a disaster to lose this feed, however, to use URL Master et al then XML would have to be registered on the ASP handlers to allow the .NET Framework to process all incoming .xml requests, something of an overkill when we only want this one instance handling.

This is where ISAPI_Rewrite comes into play.

It’s a very complex, but powerful tool.  Unfortunately, the lack of documentation didn’t make it easier, however, the following configuration file achieved everything I wanted:

   1: [ISAPI_Rewrite]


   3: RewriteEngine on


   5: RewriteCond Host: ^

   6: RewriteRule /(.*)$2 [I,RP]


   8: RewriteCond Host: ^

   9: RewriteRule /(.*)$2 [I,RP]


  11: RewriteCond Host: ^

  12: RewriteRule /(.*)$2 [I,RP]


  14: RewriteCond Host: ^

  15: RewriteRule /(.*)$2 [I,RP]


  17: # Defend your computer from some worm attacks

  18: RewriteRule .*(?:global.asa|default.ida|root.exe|..).* . [F,I,O]

  19: RewriteRule ^/rss.xml /CustomRss.aspx [L,I]

Lines 5-15 are the key host-rewriters, mapping  our various hosted domains to www(2), ensuring that we only have one location for each piece of information (a key requirement for good SEO).  I used www2 for ‘offline’ pre-release testing of the site.

Line 19 quickly allows rss.xml to be mapped to our custom rss feeder that aggregates news and blogs.