Skip to main content
TutorialsWeb Development

301 Redirects on IIS 6 with ISAPI_Rewrite

By September 8, 2010January 24th, 2024No Comments

We just launched a new site for one of our clients, and one small improvement we made was replacing all the old and ugly (and not especially SEO-friendly) URLs like /cand_jobs.shtml with shiny new ones like /jobs. The catch here is that Google’s existing index refers to all the old URLs, and we risk serving up 404’s and losing Google juice if we don’t implement 301 redirects from all the old URLs to the new ones.

On Apache, the normal way to handle this is to add lines like this to your .htaccess:

redirect 301 /old.htm

Unfortunately, in this case we aren’t using Apache–we’re using IIS 6. I could set up redirects from within IIS itself, but as far as I can tell that would require creating dummy files for each of our old URLs, and telling IIS to redirect each to their new URL, and I’m not interested in having a bunch of dummy files lying around waiting for someone to accidentally delete them. Instead, the smart way to approach the problem is via ISAPI_Rewrite, an IIS module which mimics some parts of Apache’s configuration, which we happen to already have installed.

Long story short, add this to your httpd.conf:

RewriteCond ^old.htm$ new [R=301,L]

Why is such a trivial solution worthy of a blog post? Because it took me more than an hour trying different combinations of options to find one that would work. Why? Because ISAPI_Rewrite 2’s documentation has better Google juice than ISAPI_Rewrite 3’s, and I wasted my hour scouring the wrong one and following the advice of others running that version.