Skip navigation

IIS 101: Redirection

Editor’s Note: Each month, this Web-exclusive column provides resources and answers for new IIS administrators. For more information about beginning IIS administration, be sure to check out Brett Hill’s IIS Answers (

Redirection is the main trick magicians use to perform sleight of hand: If you’re looking somewhere else, you don’t notice what they’re doing. With IIS, you can do your own bit of magic, redirecting users anywhere you want based on the criteria you choose. Several methods for redirection exist; this month, I talk briefly about three methods—built-in redirection, redirection through Active Server Pages (ASP), and redirection through an Internet Server API (ISAPI) filter.

Method 1: Using Built-in Redirection
IIS lets you specify where you want to relocate the content for a Web site or virtual directory. You specify this location on the Home Directory tab, which Figure 1 shows, for a Web site or on the Virtual Directory tab for a virtual directory. To access these tabs, right-click the Web site (or virtual directory) in Microsoft Management Console (MMC) and select Properties. When the Properties dialog box appears, click the Home Directory (or Virtual Directory) tab.

One choice is A redirection to a URL. To relocate content to a URL, enter the http:// path to the redirection and select The exact URL entered above check box. (You can use the same technique on the file’s properties within MMC to redirect an individual file as opposed to an entire Web site or virtual directory.) When you click OK or Apply, you set the redirection. You might need to stop and start the Web site for the redirection to take effect.

If you’re experienced in using built-in redirection, you might want to check out the online IIS documentation about redirection for information about using variables (e.g., $S, $P, $Q, $V, $1-9, !) in your redirection path. Variables let you perform some rather advanced manipulation without programming. For example, you can route to"yes". For details about the redirection variables, see the IIS online documentation.

Method 2: Using ASP
The built-in redirection variables referenced above give you a lot of control, but sometimes you need even more. With ASP, the extra control comes from the built-in Redirect method.

The Redirect method lets you create a page that will route users to the proper location based on the criteria you specify. Examples of ways to use this method include

  • Routing users to pages optimized for their browser
  • Routing users to a location based on group membership
  • Routing users to the proper information based on their completing a form
  • Automatically routing users back to a page to complete a transaction
  • Routing users to a page that is in the language they use

Here’s an example of the code to accomplish this type of redirection:

<% Response.Redirect = (" %>

To use this code, you need to enter your target URL in place of the example URL.

Clearly, there’s more to this process than I can go into here. I just want to introduce you to the idea. You need to know a few things about ASP to use this technique; a good place to start is the LearnASP Web site (

Method 3: ISAPI Filters
An ISAPI filter is a program through which IIS can pass all incoming and outgoing data. The program can act on that data and insert, route, or do whatever you want to it. Secure Sockets Layer (SSL) is an example of an ISAPI filter.

Writing such a filter isn’t something you can do on a whim; it requires expert knowledge of C++ and the ISAPI specifications. I mention the option here because if you often redirect users, this method provides the best performance. Redirection is a costly process in terms of time and overhead, so for some sites, an ISAPI filter is the best solution.

Next Month
You can use other methods for achieving redirection, but these three methods can accomplish most of what you would hope to do in the normal course of operations. Next month, I’ll explore the many ways in which you can use virtual directories to make your Web structure more flexible and secure.
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.