Ask Leo! by Leo A. Notenboom

Does IIS Support URL Rewriting?

Search First! Then browse: Categories | Full Archive | By Date | Newsletter

Home » Windows

Summary: URL Rewriting is a powerful was 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.
  • IIS Rewrite - featured in Microsoft's MSDN magazine.
  • OpURL.

Article C1836 - August 26, 2003

Helpful? Get new articles weekly by email in my FREE newsletter!

Your Name:
Your Email:


Why Subscribe?

Recent Comments
16 Comments

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

Posted by: Ionic Shade at June 7, 2006 3:01 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.

Posted by: Phil Crosby at September 21, 2006 2:25 PM

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

Greg Stanley
www.flashtoybox.com

Posted by: gstanley at November 28, 2006 4:35 PM

You can always use meta refresh tags.

Posted by: Leo Notenboom at November 28, 2006 4:39 PM

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.

Posted by: Tony Cheetham at December 5, 2006 3:12 AM

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.

Posted by: micronovae at June 21, 2007 6:09 PM

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

Posted by: yrm at September 27, 2007 5:46 PM

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/

Posted by: Ruslan Yakushev at July 21, 2008 9:41 AM

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
Posted by: Tom at October 1, 2008 2:47 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.

Posted by: Seris at October 7, 2008 8:57 PM

Post a comment on "Does IIS Support URL Rewriting?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

  • Read the article at the top of this page. If your comment shows you didn't, it'll be deleted and ignored.

  • Comment only on this article. Use the Google search box at the top of the page if you have a question about something else.

  • Don't include personal information in the comment. No email addresses. No phone numbers. No physical addresses.

  • Don't spam. Excessive links to unrelated sites within a comment or across multiple comments will cause all such comments to be removed.

  • Don't ask me to recover lost passwords or hacked accounts. I can't, and those comments will be deleted.

  • I can't respond to every comment. And I can't vouch for the accuracy of others who do.

Please wait. Your comment is being processed ...


Question? Ask Leo!