Friday, December 24, 2010

IIS Redirect Variables

Not sure how I had not been aware of these before, but discovered the power of IIS Redirect Variables today whilst looking for a way to redirect requests, but include the query string.

Source: http://support.microsoft.com/kb/313074

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:

The $S variable 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. The server automatically performs this suffix substitution. The $S variable is used only in combination with other variables. If /Scripts is redirected to /NewScripts and the original request is for /Scripts/Program.exe, the suffix is /Program.exe.

The $P variable passes the parameters in the original URL without the question mark that is used to specify the beginning of the query string. If the original URL is /Scripts/MyScript.asp?number=1, the string "number=1" is mapped into the destination URL.

The $Q variable passes the full query string (the question mark and the parameters) from the original URL. If the original URL is /Scripts/MyScript.asp?number=1, the string "?number=1" is mapped into the destination URL.

The $V variable passes the requested URL, without the server name. If the original URL is /Myserver/Scripts/MyScript.asp, the string "/Scripts/MyScript.asp" is mapped into the destination URL.

The variables $0 through $9 pass the portion of the requested URL that matches the indicated wildcard.

! Do not redirect. Use this variable to prevent redirecting a folder or an individual file.

No comments: