Removing the trailing slash from a URL in IIS6

For SEO reasons, it's sometimes considered a bad thing to have the same content on two URLs. The preferred method for fixing this is canonical URLs - however if this is not possible you can use URL rewriting to do this. If you are using IIS7 there is a URL Rewriter module, but if you're stuck with IIS6 you can use the method below.

Step 1

Install the free ISAPI filter from here

Step 2

Run the installer, pick a site to install it on. This just adds a reference to the ISAPI filter as below. You can check it worked by the following URL http://{websiteURL}/iirfStatus (NB. you must be on the server with remote desktop to run this URL)

Step 3

Duplicate the above ISAPI filter on any other sites you need it to work on

Step 4

Add the following text file in the root folder of the website, call the file iirf.ini

RewriteEngine ON
StatusUrl /iirfStatus

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301,L]

Step 5

Make yourself a celebratory cup of tea and pat yourself on the back for being so smart (or run for the hills when everything goes bad).