URL Rewriting with Ionic ISAPI Rewrite
July 7th, 2009 — Brian FooteA while back I started noticing people with business cards for large companies with easy to remember urls to their personal pages which had their name after the site address like ‘www.facebook.com/[name]‘. I needed to implement this for a client where they wanted their sales affiliates to be able to create shortcuts like this they could hand out to customers or print on litererature etc. When customers click the link they get a cookie associating them with the affiliate and any purchases they make after that get assigned to the appropriate affiliate. I discovered a cool utility Ionic ISAPI Rewrite which adds this functionality to IIS.
Ionic Rewrite installs as an ISAPI filter with a couple of configuration files that are easy to setup. The only problem I had was when I installed it I had an invalid path for the RewriteLog setting which prevented it from working at all until I entered a valid path.
PCRE regex is fully supported so with a simple query setting like:
RewriteRule (?!^/guru_admin)(?!.*\/$)^/([^.]+)$ http://www.gurubyte.com/1.html?p=$1&w=GURU [I,R]
Which in English means:
-does not begin with /guru_admin (ignores this directory)
-does not end in a slash
-does not end with an extension
Addresses matching the rule get sent to the more complex 1.html file and the querystring is populated dynamically with the p parameter set dynamically to the text denoted with the $ in the rule. Using this method I am able to support affiliate url codes with no programming!
