Technology in terms you understand. Sign up for the Confident Computing newsletter for weekly solutions to make your life easier. Click here and get The Ask Leo! Guide to Staying Safe on the Internet — FREE Edition as my thank you for subscribing!

Does IIS 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.

Become a Patron of Ask Leo! and go ad-free!

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.

Subscribe to Confident Computing! Tech problem solving & safety tips with a weekly confidence boost in your inbox every week.

I'll see you there!

10 Reasons Your Computer is Slow

Slow Computer?

Speed up with my FREE special report: 10 Reasons Your Computer is Slow, now updated for Windows 10.

No strings. No email. Here's the direct download. (Just right-click and "Save As...".)

22 comments on “Does IIS Support URL Rewriting?”

  1. 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.

    Reply
  2. 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.

    Reply
  3. 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.

    Reply
  4. 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
    Reply
  5. 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.

    Reply
  6. 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.

    Reply
  7. 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.

    Reply

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.