Fun with ISAPI Filters

written by Scott Watermasysk on Monday, April 28 2008

I am a big fan of ISAPI filters and ISAPI_Rewrite in particular. If you are not familiar with ISAPI filters and ISAPI_Rewrite, in a nutshell:

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions. It acts mostly like Apache's mod_Rewrite, but is designed specifically for Microsoft's Internet Information Server (IIS).

For $99 a server, you cannot go wrong (although there is a nice free open source version as well.)

There are many SEO and redirect usages of the product. One of my favorites is cleaning up and simplifying urls to make them more readable and emailable.

RewriteRule /search/([a-zA-Z0-9\-\._:]*?)/ /search/?q=$1 [I,L]
RewriteRule /search/([a-zA-Z0-9\-\._:]*?)/\?p=(\d+) /search/?q=$1&p=$2 [I,L]

Using the example code above, I can now build and share search links in my blog (using Graffiti) like this: http://simpable.com/search/graffiti/ (instead of http://simpable.com/search/?q=graffiti). I won't go into all of the ins and outs of ISAPI_Rewrite, but basically:

  • Declare a new rule
  • Provide a regex pattern
  • Provide a url to direct the request to (in this case the Graffiti search url)
  • (optional) Add parameters/settings

Similar Posts

  1. Graffiti CMS FAQ
  2. Simplifying ASP.Net - NVelocity
  3. Castle Project

Trackbacks

Use the following link to trackback from your own site:
http://simpable.com/trackback.ashx?id=70

Comments

  • Bill Robertson on on 5.01.2008 at 12:54 PM

    Bill Robertson avatar

    I also second ISAPI_Rewrite. With .net application you have to create directories for everything before the runtime will process it. With one regex pattern you can force every piece on content into a querystring driven handler page without creating 1000's of directories.

Post a comment