Training
Certifications
Books
Special Offers
Community




 
Microsoft® Windows® 2000 and IIS 5.0 Administrator's Pocket Consultant
Author William R. Stanek
Pages 396
Disk N/A
Level All Levels
Published 04/04/2001
ISBN 9780735610248
ISBN-10 0-7356-1024-X
Price(USD) $29.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 


Chapter 3: Configuring Web Sites and Servers continued


Redirecting Browser Requests

Browser redirection is a useful technique to prevent errors when you rename or delete content within a Web site. When you redirect requests, you tell a browser to take the following actions:

  • Look for files in another directory.
  • Look for files on a different Web site.
  • Look for files on another computer.
  • Look for a specific file instead of a set of files.
  • Run an ISAPI application instead of accessing the requested files.

Each of these redirection techniques is examined in the sections that follow. Tips for creating customized redirection routines are examined in the "Customizing Browser Redirection" section of this chapter.

Redirecting Requests to Other Directories or Web Sites

If you rename or delete a directory, you can redirect requests for files in the directory to another directory or Web site. When a browser requests the file at the original location, the Web server instructs the browser to request the page using the new location. You redirect requests to other directories or Web sites as follows:

  1. In the Internet Information Services snap-in, click the plus sign (+) next to the Web site you want to work with.
  2. Right-click the directory you want to redirect and then select Properties.
  3. Click the Virtual Directory or Directory tab as appropriate, and then select A Redirection To A URL, as shown in Figure 3-10.
  4. Click to view graphic
    Click to view graphic

    Figure 3-10.  You can redirect requests for files in one directory to another directory.

  5. In the Redirect To field, type the URL of the destination directory or Web site. For example, to redirect all requests for files in the /Docs directory to the /CorpDocs directory, type /CorpDocs. To redirect all requests for files located at www.microsoft.com/Docs to the techsupport.microsoft.com/CorpDocs, type http://techsupport.microsoft.com/CorpDocs.
  6. Click OK. Now all requests for files in the old directory are mapped to files in the new directory. For example, if the browser requested /Docs/adminguide.doc and you redirected requests to http://techsupport.microsoft.com/CorpDocs/, the browser would request http://techsupport.microsoft.com/CorpDocs/adminguide.doc.

Redirecting All Requests to Another Web Site

If you stop publishing a Web site but don’t want users to reach a dead end if they visit, you should redirect requests for the old Web site to a specific page at the new site. You redirect requests to a specific page at another site by completing the following steps:

  1. In the Internet Information Services snap-in, right-click the Web site you want to work with, and then select Properties.
  2. Click the Home Directory tab and then select A Redirection To A URL, as shown in Figure 3-11.
  3. Click to view graphic
    Click to view graphic

    Figure 3-11.  Another redirection technique is to redirect all requests for files to a specific location at another Web site.

  4. In the Redirect To field, type the complete URL path to the page at the new site, such as /oldsite.html.
  5. Select The Exact URL Entered Above and then click OK. Now all requests for files at the old site are mapped to a specific page at the new site.

Retrieving Files from a Network Share

IIS can retrieve files from a network share instead of the local hard drive. To configure this, complete the following steps:

  1. In the Internet Information Services snap-in, right-click the Web site you want to work with, and then select Properties.
  2. Click the Home Directory tab and then select A Share Located On Another Computer, as shown in Figure 3-12.
  3. Type the UNC path to the network share in the Network Directory field. The path should be in the form \\ServerName\SharedFolder, such as \\Gandolf\CorpWWW. Afterward, click Connect As and then enter the username and password that should be used to connect to the shared folder.
  4. Click OK. Now all requests for files on the Web site are mapped to files on the specified network share.
  5. Click to view graphic
    Click to view graphic

    Figure 3-12.  Network shares can be used as source directories for content. To map to a share, you must use redirection.

Redirecting Requests to Applications

If your organization’s development team has created a custom application for the Web site, you can redirect all requests for files in a particular directory (or for the entire site, for that matter) to an application. Parameters passed in the URL can also be passed to the application; the technique you use to do this is as follows:

  1. In the Internet Information Services snap-in, click the plus sign (+) next to the Web site you want to work with.
  2. Right-click the directory you want to redirect and then select Properties. If you want to redirect all requests for the site, right-click the Web site entry and then select Properties.
  3. Click the Home Directory, Virtual Directory, or Directory tab as appropriate, and then select A Redirection To A URL.
  4. In the Redirection To field, type the URL of the application including any variables needed to pass parameters to the program, such as /CorpApps/Login.exe?URL=$V+PARAMS=$P, where $V and $P are redirection variables. A complete list of redirect variables is provided in Table 3-1.
  5. Select The Exact URL Entered Above and click OK. Now all requests for files in the directory or site are mapped to the application.

Customizing Browser Redirection

The previous sections looked at basic redirection techniques. Now it’s time to break out the power tools and customize the redirection process. You can customize redirection anytime you select the A Redirection To A URL option.

In all of the previous discussions, when you selected A Redirection To A URL, additional options were displayed under The Client Will Be Sent To. Without selecting additional options, all requests for files in the old location were mapped automatically to files in the new location. You can change this behavior by selecting any of the following options under The Client Will Be Sent To:

  • The Exact URL Entered Above  Redirects requests to the destination URL without adding any other portions of the original URL. You can use this option to redirect an entire site or directory to one file. For example, to redirect all requests for the /Downloads directory to the file DOWNLOAD.HTM in the home directory, select this option and then type /DOWNLOAD.HTM in the Redirect To text box.
  • A Directory Below This One  Redirects a parent directory to a child directory. For example, to redirect your home directory (designated by /) to a subdirectory named /Current, select this option and then type /Current in the Redirect To text box.
  • A Permanent Redirection For This Resource  Sends a "301—Permanent Redirect" message to the client. Without using this option, redirections are considered temporary, and the client browser receives the "302—Temporary Redirect" message. Some browsers can use the "301—Permanent Redirect" message as the signal to permanently change a URL stored in cache or in a bookmark.

You can customize redirection using redirect variables as well. As Table 3-1 shows, you can use redirect variables to pass portions of the original URL to a destination path or to prevent redirection of a specific file or subdirectory.

Table 3-1.  Redirect Variables for IIS

VariableDescriptionExample
$SPasses the matched suffix of the requested URL. The server automatically performs this suffix substitution; you use the $S variable only in combination with other variables.If /Corpapps is redirected to /Apps and the original request is for /Corpapps/LOGIN.EXE, then /LOGIN.EXE is the suffix.
$PPasses the parameters in the original URL omitting the question mark used to specify the beginning of a query string.If the original URL is /Scripts /COUNT.ASP?valA=1&valB=2, then the string "valA=1&valB=2" is mapped into the destination URL.
$QPasses the full query string to the destination.If the original URL is /Scripts/COUNT.ASP?valA=1&valB=2, then the string "?valA=1&valB=2" is mapped into the destination URL.
$VPasses the requested path without the server name.If the original URL is //Gandolf/Apps/COUNT.ASP, then the string "/Apps/COUNT.ASP" is mapped into the destination URL.
$0 through $9Passes the portion of the requested URL that matches the indicated wildcard. 
!Use this variable to prevent redirecting a subdirectory or an individual file. 

The final way you can customize redirection is to use redirect wildcards. Use redirect wildcards to redirect particular types of files to a specific file at the destination. For example, you can use redirect wildcards to redirect all .htm files to DEFAULT.HTM and all .asp files to DEFAULT.ASP. The syntax for wildcard redirection is:

*;*.EXT;FILENAME.EXT[;*.EXT;FILENAME.EXT…]

where .ext is the file extension you want to redirect and FILENAME.EXT is the name of the file to use at the destination. As shown, begin the destination URL with an asterisk and a semicolon, and separate pairs of wildcards and destination URLs with a semicolon. Be sure to account for all document types that users may requests directly, such as .htm, .html, and .asp documents.

You can use wildcard redirection by completing the following steps:

  1. In the Internet Information Services snap-in, click the plus sign (+) next to the Web site you want to work with.
  2. Right-click the directory you want to redirect and then select Properties. If you want to redirect all requests for the site, right-click the Web site entry, and then select Properties.
  3. Click the Home Directory, Virtual Directory, or Directory tab as appropriate, and then select A Redirection To A URL.
  4. In the Redirection To field, type the wildcard redirection values. For example, if you want to redirect wildcards to redirect all .htm files to DEFAULT.HTM and all .asp files to DEFAULT.ASP, you would enter:
  5. *;*.HTM;DEFAULT.HTM;*.ASP;DEFAULT.ASP

  6. Select The Exact URL Entered Above and then click OK. Now all requests for files in the directory or site are mapped using wildcards, if possible.


Previous   |  Table of Contents   |  Next




Top of Page


Last Updated: Friday, July 6, 2001