Microsoft KB Archive/313074

= How To Redirect Browser Requests in Internet Information Services 5.0 =

Article ID: 313074

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q313074



IN THIS TASK
SUMMARY How to Redirect Browser Requests to Another Folder or Web Site How to Redirect Browser Requests to a File How to Redirect Browser Requests to a Network Share How to Redirect Browser Requests to a Program How to Customize Browser Redirection
 * URL Redirection Options
 * Redirect Variables
 * Redirect Wildcards

REFERENCES



SUMMARY
This step-by-step article describes how to redirect browser requests to another folder, a file, a network share, or a program in Internet Information Services (IIS) 5.0.

When a browser requests a page on a Web site, the Web server locates the page that is identified by the uniform resource locator (URL), and then returns it to the browser. If you either move pages, rename virtual directories, or make other changes to your Web content, use IIS to redirect the client computer request to the new location to ensure that browsers can locate a page at the new location. After the browser requests the file at the original URL, IIS instructs the browser to use the new URL to request the page.

You can use IIS to perform any of the following browser redirection procedures:
 * Redirect requests to another folder or Web site.
 * Redirect requests to a file.
 * Redirect requests to a network share.
 * Redirect requests to a program.

You may want to redirect browser requests in any of the following scenarios:
 * Your Web site is still under construction.
 * You update your site and you want to make a portion of your Web site temporarily unavailable.
 * You either rename or delete a virtual directory and you want the hyperlinks in the original virtual directory to access the same files in the new virtual directory.

back to the top

How to Redirect Browser Requests to Another Folder or Web Site
To redirect browser requests to another folder or Web site:
 * 1) Start Internet Services Manager.

Alternatively, start the IIS Snap-in in Microsoft Management Console (MMC).
 * 1) Click to expand *  , where   is the name of the server.
 * 2) Right-click either the Web site or the folder that you want to redirect, and then click Properties.
 * 3) Click one of the following tabs that is appropriate to your situation:
 * 4) * Home Directory
 * 5) * Virtual Directory
 * 6) * Directory
 * 7) Under When connecting to this resource, the content should come from, click A redirection to a URL.
 * 8) Type the URL of the destination folder or Web site in the Redirect to box.

For example, to redirect all requests for files in the Products folder to the NewProducts folder, type /NewProducts. To redirect all requests for files located at www.mycompany.com/products to sales.mycompany.com/newproducts, type http://sales.mycompany.com/newproducts.
 * 1) Click OK.

back to the top

How to Redirect Browser Requests to a File
To redirect browser requests to a file:  Start Internet Services Manager.

Alternatively, start the IIS Snap-in in Microsoft Management Console (MMC). Click to expand * , where   is the name of the server. Right-click either the Web site or folder that you want to redirect, and then click Properties. Click one of the following tabs that is appropriate to your situation:  Home Directory Virtual Directory Directory</li></ul>

</li> Under When connecting to this resource, the content should come from, click A redirection to a URL.</li> Type the URL of the destination file in the Redirect to box.

For example, to redirect all requests for files in the Products virtual directory to the Default.htm file in the home folder, type /Default.htm .</li> Under The client will be sent to, click to select the The exact URL entered above check box.</li> Click OK.</li></ol>

back to the top

How to Redirect Browser Requests to a Network Share
You can use network shares as source folders for Web content by redirecting client requests to the network share. To map a network share: <ol> Start Internet Services Manager.

Alternatively, start the IIS Snap-in in Microsoft Management Console (MMC).</li> Click to expand * , where   is the name of the server.</li> Right-click either the Web site or the folder that you want to redirect, and then click Properties.</li> Click one of the following tabs that is appropriate to your situation: <ul> Home Directory</li> Virtual Directory</li> Directory</li></ul>

</li> Under When connecting to this resource, the content should come from, click A share located on another computer.</li> Type the UNC path to the network share by using the \\ \ format in the Network Directory box.

For example, type \\MyServer\MyShare .</li> Click Connect As, click Browse, click the user account that has permission to access the network share, and then click OK.</li> Type the password of the user account that you selected, and then click OK.</li> <li>Click OK.</li></ol>

back to the top

How to Redirect Browser Requests to a Program
If you develop a custom program for your Web site, you can redirect browser requests to the program. To redirect browser requests to a program: <ol> <li>Start Internet Services Manager.

Alternatively, start the IIS Snap-in in Microsoft Management Console (MMC).</li> <li>Click to expand * , where   is the name of the server.</li> <li>Right-click either the Web site or the folder that you want to redirect, and then click Properties.</li> <li>Click one of the following tabs that is appropriate to your situation: <ul> <li>Home Directory</li> <li>Virtual Directory</li> <li>Directory</li></ul>

</li> <li>Under When connecting to this resource, the content should come from, click A redirection to a URL.</li> <li>Type the URL of the program in the Redirect to box.

Make sure that you include any redirect variables that are necessary to pass parameters to the program. For example, to redirect all requests for scripts in the Scripts folder to a logging program (Logger.exe) that records the requested URL and any parameters that are passed with the URL, type /Scripts/Logger.exe?URL=$V+PARAMS=$P, where $V and $P are redirection variables.

For more information about redirect variables, see the Redirect Variables section of this article.</li> <li>Under The client will be sent to, click to select the The exact URL entered above check box.

This option redirects the request without appending any portions of the original URL to the destination URL.</li> <li>Click OK.</li></ol>

back to the top

How to Customize Browser Redirection
When you click A redirection to a URL on either the Home Directory, the Virtual Directory or the Directory tab of the Web site or the folder that you want to redirect, requests for files in the original location are automatically redirected to the destination that you specify in the Redirect to box.

Use any of the following methods to customize how you want to redirect browser requests:
 * Specify URL redirection options.
 * Use redirect variables to pass portions of the original URL with the destination URL.
 * Use redirect wildcards to redirect specific types of files to a particular file.

back to the top

URL Redirection Options
To customize URL redirection, click to select any of the following check boxes under The client will be sent to:
 * The exact URL entered above

Click to select this check box to redirect a virtual directory to the destination URL without appending a portion of the original URL. Use this setting if you want to redirect a Web site or virtual directory to a single file. For example, to redirect all requests for the Scripts virtual directory to the Default.htm file in the home directory, type /Default.htm in the Redirect to box, and then click to select this check box.
 * A directory below this one

Click to select this check box to redirect a parent directory to a child directory. For example, to redirect your home directory (designated by /) to a subfolder named &quot;NewHome&quot;, type /NewHome in the Redirect to box, and then click to select this check box. If you do not use this setting, the Web server maps the parent directory to itself.
 * A permanent redirection for this resource.

If you click to select this check box, the server sends a &quot;301 Permanent Redirect&quot; message to the client. If you do not use this setting, redirect processes are temporary, and the client browser receives a &quot;302 Temporary Redirect&quot; message. Some browsers can use the &quot;301 Permanent Redirect&quot; message as a signal to permanently change a URL, such as a bookmark.

back to the top

Redirect Variables
Use Redirect variables to either pass portions of the original URL with the destination URL or to prevent redirection of a specific file or folder. The following table lists the redirect variables that you can use in the Redirect to box and provides an example of each:

back to the top

Redirect Wildcards
Use redirect wildcards to redirect specific types of files to a particular file at the destination. Use the wildcard character (*) in the Redirect to box to match any number of characters in the original URL.

To use wildcard redirection: <ol> <li>Start Internet Services Manager.

Alternatively, start the IIS Snap-in in Microsoft Management Console (MMC).</li> <li>Click to expand * , where   is the name of the server.</li> <li>Right-click either the Web site or the folder that you want to redirect, and then click Properties.</li> <li>Click one of the following tabs that is appropriate to your situation: <ul> <li>Home Directory</li> <li>Virtual Directory</li> <li>Directory</li></ul>

</li> <li>Under When connecting to this resource, the content should come from, click A redirection to a URL.</li> <li>In the Redirect to box, type the wildcard redirection values in the following format, where  is the extension of the file that you want to redirect, and   is the destination file name:

Make sure that you start the destination URL with an asterisk (*) and a semicolon, and you start separate pairs of wildcards and destination URLs with a semicolon.

For example, to redirect all requests for Scripts/Filename.stm to a single file called &quot;Default.stm,&quot; and to redirect all requests for Scripts/Filename.htm to a single file called &quot;Default.htm,&quot; type the following line for the Scripts virtual directory:

*;*.stm;/default.stm;*.htm;/default.htm

</li> <li>Under The client will be sent to, click to select the The exact URL entered above check box.</li> <li>Click OK.</li></ol>

back to the top

<div class="references_section">