Helping people with computers... one answer at a time.

URL Rewriting is a powerful way for webmasters to control what a URL really represents. IIS requires an extension in order to support url rewriting.

Does IIS Support URL Rewriting?

No. But then again yes. Let me explain ...

URL Rewriting is a technique available on many web servers that allows you the web master to make changes to URLs requested by clients before they are processed by your web server.

This one is best described by example. In a prior entry here I talked about using redir.pl to allow you to log and or redirect when people click an external link on your site. On the Ask Leo site the links that used redir.pl look like this:

http://ask-leo.com/cgi-bin/redir.pl?ms

That example link will take you to http://www.microsoft.com.

Even though redir.pl lets you make short URLs out of long ones, it still seems rather long and convoluted. And if you care about such things, many search engine crawlers will not index pages that contain "?" in their URLs.

Enter URL re-writing. Using URL re-writing, I can specify that any instance of "r-" in an incoming URL be replaced with "cgi-bin/redir.pl?". Then my redirected link looks like this:

http://ask-leo.com/r-ms

The URL redirector intercepts the incoming request, replaces "r-" with "cgi-bin/redir.pl?", and passes the result on to IIS for processing.

My example is quite literal - on this site I replace any instance of "r-", which means of course that I cannot use "r-" anywhere else in any of my URLs. That's something I'm willing to live with for simplicity. However most URL rewriters use regular expressions for pattern matching and replacing, so you can get quite specific and restrictive if specifying exactly what should get replaced and when.

IIS does not support URL rewriting itself. Rather, it supports an extension interface called ISAPI which allows add-ons to be installed into IIS. Add-ons like URL rewriters, for example.

Here are a few of the available rewriters at this writing:

  • ISAPI_rewrite - In addition to a full featured main product, there's a free "lite" version for single site servers and for testing the concept.
  • OpURL.

Article C1836 - August 26, 2003 « »

Share this article with your friends:

Share this article on Facebook Tweet this article Email a link to this article
Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

22 Comments
Dave
September 16, 2003 8:19 PM

I can't believe you have to pay for this simple functionality. God bless open source software like Apache.

Mike Bridge
March 1, 2005 3:55 PM

I agree with the other comment. This is such a basic piece of web server functionality that it's ridiculous that there's no equivalent to mod_rewrite (or the various other similar FREE modules) in Apache.

I guess it shouldn't be a surprise why Apache has 70% of the market share and rising.

Sigh.

Jason
April 7, 2005 1:23 AM

I finally found a free IIS URL rewrite tool after weeks of searching.. right here:

http://www.iistoolshed.com/

sedgemonkey
May 12, 2005 1:59 PM

I wouldn't mind springing $50 for a good solution but it seems you have to update software version when migrating between OS (2000 to 2003) and service pack updates. Too much maintenance.

Alex
August 16, 2005 1:49 AM

URL Rewrite for MS IIS
http://www.smalig.com/url_rewrite/

Steven
September 8, 2005 2:23 AM

Hi All,

I recently released mod_rewrite for IIS free and as opensource.

Check it out at http://www.iismods.com. If you like the filter just let othe people know :), programmers to help me out are more than welcome!

Regards
Steven

Ionic Shade
June 7, 2006 3:01 PM

Ionic's ISAPI Rewrite Filter -
http://cheeso.members.winisp.net/IIRF.aspx
free. Regular Expressions. Redirects, Rewrites. RewriteCond. checkitout.

Phil Crosby
September 21, 2006 2:25 PM

There are also a few rewriting options from within ASP.NET, although they're not great. I've written up an overview of what you can do here:

http://philisoft.com/blog/url-rewriting-in-iis/

I ended up using Ionic's rewrite filter, works great.

gstanley
November 28, 2006 4:35 PM

Is this the only way to redirect .htm or .html files on an IIS Server?

Greg Stanley
www.flashtoybox.com

Leo Notenboom
November 28, 2006 4:39 PM

You can always use meta refresh tags.

Tony Cheetham
December 5, 2006 3:12 AM

You can also use a custom 404 error page to catch missing urls(Or rewrite urls in this case), and then server.transfer to the correct page, or redirect.

micronovae
June 21, 2007 6:09 PM

Micronovae has recently released IIS Mod-Rewrite v2.0

http://www.micronovae.com/ModRewrite/ModRewrite.html

This URL rewriting module for IIS is compatible with Apache mod_rewrite, and it's Pro version is the only solution in the market that supports .htaccess configurations.

yrm
September 27, 2007 5:46 PM

For rewrite url, there is Guideman.
http://na-s.jp/Guideman/index.en.html

Ruslan Yakushev
July 21, 2008 9:41 AM

Microsoft IIS team has released a technical preview of the URL rewrite module for IIS 7.0. This module, when final version ships, will be officially supported by Microsoft. You can get more information about it and download technical preview from here: http://learn.iis.net/page.aspx/460/using-url-rewrite-module/

Tom
October 1, 2008 2:47 PM

Hi guys, I have a question: Currenclty I use a 404 pages to perform a basic URL rewriting, that works perfectly so I am asking why there is a such plugins on IIS? Is there a performance issue?

Cheers

Technically yes, a URL rewriting solution can be faster. However not everything people want to rewrite would generate a 404. For example "www.ask-leo.com" would work but I URL-rewrite it to "ask-leo.com" so all URLs are consistant.
- Leo
02-Oct-2008
Seris
October 7, 2008 8:57 PM

Using a 404 pages to perform a basic URL rewriting is Good. But not support 304 Not Modified to increase performance by validation caching.

Nizar
February 19, 2010 3:16 AM

Can I redirect my /index.php to / using the Ionic's ISAPI Rewrite Filter? Or is there any easier way to do this ?

Andrew
March 14, 2010 2:03 PM

I used ISAPI_Rewrite myself. Nice stuff, does a lot. As a result a switched to Helicon Ape - Apache emulator for IIS. It has a rich functionality mod_rewrite, mod_proxy, mod_auth, mod_gzip, mod_headers, mod_cache, mod_expires, mod_developer, mod_replace, mod_so, mod_speling, mod_usertrack and others.

Salman
February 25, 2011 5:01 AM

You can have PATHINFO style URLs on IIS. They do not require any components and look reasonably OK. An example of a such URL would is:

http://localhost/app/index.php/products/1234/details

Technically speaking, this is not apache/htaccess style URL "rewriting" but this kind of URL is still better than http://localhost/app/product-etail.php?id=1234 in terms of SEO.

Also, unlike htaccess style rewriting which is almost transparent, this technique requires "coding" changes so that your scripts check for a server variable called "PATH_INFO" instead of/in addition to checking query strings.

technical support Vancouver Wshington
May 19, 2011 7:25 AM

IIS does not support URL rewriting itself. Rather, it supports an extension interface called ISAPI which allows add-ons to be installed into IIS.

Kaushal Shah
November 9, 2011 10:29 AM

hi,
I am looking for the example link where there are steps to do the URL shortening via IIS ISAPI. I want the link which has screen shots also so that its easy to understand how it works. does anybody knows about any such links? please let me know if there are any.

Roxann Demmel
April 5, 2012 2:54 PM

As a site owner I believe the subject matter here is reallyfantastic. I appreciate it for your efforts. You should keep it up forever! Best of luck.

Comments on this entry are closed.

If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.

If you don't find your answer, head out to http://askleo.com/ask to ask your question.