Redirecting Requests to Files, Directories, or Programs
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1
You can redirect requests for files in one directory to a different directory, to a different Web site, or to a file in a different directory. When the browser requests the file from the original URL, the Web server instructs the browser to request the page from the redirected URL.
An advanced capability of the redirect method allows you to redirect all requests for files in a particular directory to a program. Generally speaking, you should also pass any parameters from the original URL to the program, which you can do by using redirect variables.
Important
You must be a member of the Administrators group on the local computer to perform the following procedure or procedures. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run IIS Manager as an administrator. At a command prompt, type runas /User:Administrative_AccountName "mmc %systemroot%\system32\inetsrv\iis.msc".
Procedures
To redirect requests to another directory or Web site
In IIS Manager, expand the local computer, right-click the Web site, virtual directory, or directory within a Web site to which you want to add a redirect, and click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this resource should come from, click A redirection to a URL.
In the Redirect to box, type the path to the destination directory or the URL of the Web site. For example, to redirect all requests for files in the /Catalog directory to the /NewCatalog directory on another Web site, type https://sitename/NewCatalog. The redirect must be to a fully qualified URL.
Set the required flags as specified below, and then click OK. More than one flag is allowed.
Select The exact URL entered above to indicate that the value provided for the destination is an absolute target location.
Select A directory below this one to indicate that redirection should occur only once, because the destination is in a subdirectory of the original URL. This setting also instructs IIS to redirect requests only if they are to subfolders or files of the original URL.
Select A permanent redirection for this resource to indicate that this redirection is permanent for this resource.
Clear A permanent redirection for this resource to indicate that this redirection is temporary for this resource.
To redirect all requests to a single file
In IIS Manager, right-click the Web site or directory, and click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this resource should come from, click A redirection to a URL.
In the Redirect to box, type the URL of the destination file. The redirect must be to a fully qualified URL.
Under The client will be sent to, select The exact URL entered above check box to prevent the Web server from appending the original file name to the destination URL.
Click OK.
You can use wildcards and redirect variables in the destination URL to precisely control how the original URL is translated into the destination URL.
To redirect requests to a program
In IIS Manager, right-click the Web site or directory, and click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this resource should come from, click A redirection to a URL.
In the Redirect to box, type the URL of the program, including any redirect variables needed to pass parameters to the program.
For example, to redirect all requests for scripts in a Scripts directory to a logging program that records the requested URL and any parameters passed with the URL, type /Scripts/Logger.exe?URL=$V+PARAMS=$P. $V and $P are redirect variables.
Under The client will be sent to, select The exact URL entered above check box to prevent the Web server from appending the original file name to the destination URL.
Click OK.
Related Information
- For more information about writing redirection strings with variables and flags, see the Redirect Reference.