Redirecting a client's request is one way to ensure that users get the correct page if your site is under construction or has changed identity. You can redirect client requests to a directory on the server running IIS, a UNC share located on a different computer, or a different URL.
You can use redirect variables to pass portions of the original URL with the destination URL. These variables can be used by opening a directory's property sheets in the IIS snap-in and then clicking the Home Directory, Virtual Directory, or Directory tab.
Variable | Description | Example |
---|---|---|
$S | Passes the matched suffix of the requested URL. The matched suffix is the portion of the original URL that remains after the redirected URL is substituted. | if /scripts is redirected to /newscripts and the original request is for /scripts/program.exe, then /program.exe is the suffix. The server automatically performs this suffix substitution; you use the $S variable only in combination with other variables. |
$P | Passes the parameters in the original URL. | For example, if the original URL is /scripts/myscript.asp?number=1, then the string "number=1" is mapped into the destination URL. |
$Q | Passes both the question mark and the parameters from the original URL. | For example, if the original URL is /scripts/myscript.asp?number=1, then the string "?number=1" is mapped into the destination URL. |
$V | Passes the requested URL, without the server name. | For example, if the original URL is //myserver/scripts/myscript.asp, then the string "/scripts/myscript.asp" is mapped into the destination URL. |
$0 through $9 | Passes the portion of the requested URL that matches the indicated wildcard. | |
! | Do not redirect. | Use this variable to prevent redirecting a subdirectory or an individual file in a virtual directory that has been redirected. |
You can use redirect wildcards to match any number of characters in the original URL. Insert the wildcard character (*) in the Redirect To text box in a directory's Home Directory, Virtual Directory, or Directory tab. Begin the destination URL with an asterisk and a semicolon and 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 Default.stm, and to redirect all requests for /scripts/filename.htm to a single file called Default.htm, type the following in the Redirect To text box for the /scripts virtual directory:
*;*.stm;/default.stm;*.htm;/default.htm
When you use wildcards, be sure to select The exact URL entered above check box. For a redirected path, type in a URL.
Related Topics
For conceptual information on redirects, see Reroute Requests with Redirects in About Web Site Management.