Managing Directories


The directory structure of IIS is based primarily on the Windows Server 2003 file system, but it also provides additional functionality and flexibility. Understanding these complexities is critical to successfully managing IIS Web sites.

Understanding Physical and Virtual Directory Structures

Earlier in this chapter, I discussed home directories and how they were used. Beyond home directories, Microsoft Web sites also use the following:

  • Physical directories

  • Virtual directories

The difference between physical and virtual directories is important. A physical directory is part of the file system and to be available through IIS, it must exist as a subdirectory within the home directory. A virtual directory is a directory that isn’t necessarily contained in the home directory but is available to clients through an alias. Physical directories and virtual directories are configured and managed with the IIS snap-in, but they’re displayed differently. Physical directories are indicated with a standard folder icon. Virtual directories are indicated using a folder icon with a globe in the corner.

Both physical and virtual directories have permissions and properties that you can set at the operating system level and the IIS level. You set operating system permissions and properties in Windows Explorer. You set IIS permissions and properties in the IIS snap-in.

You create physical directories by creating subdirectories within the home directory using Windows Explorer. You access these subdirectories by appending the directory name to the DNS name for the Web site. For example, you create a Web site with the DNS name products.microsoft.com. Users are able to access the Web site using the URL http://www.microsoft.com/. You then create a subdirectory within the home directory called “search.” Users are able to access the subdirectory using the URL path http://www.microsoft.com/search/.

Even though locating your content files and directories within the home directory makes it easier to manage a Web site, you can also use virtual directories. Virtual directories act as pointers to directories that aren’t located in the home directory. You access virtual directories by appending the directory alias to the DNS name for the site. If, for example, your home directory is D:\Inetpub\Wwwroot and you store Microsoft Word documents in E:\Worddocs, you would need to create a virtual directory that points to the actual directory location. If the alias is docs for the E:\Worddocs directory, visitors to the www.microsoft.com Web site could access the directory using the URL path http://www.microsoft.com/docs/.

Creating Physical Directories

Within the home directory, you can create subdirectories to help organize your site’s documents. You can create subdirectories within the home directory by completing the following steps:

  1. Start Windows Explorer. Click Start, choose All Programs, Accessories, and finally Windows Explorer.

  2. In the Folders pane, select the home directory for the Web site.

  3. In the Contents pane, right-click a blank area and select New, then Folder from the shortcut menu. A new folder is added to the Contents pane. The default name is initialized to New Folder and selected for editing.

  4. Edit the name of the folder and press Enter. The best directory names are short but descriptive, such as Images, WordDocs, or Downloads.

    Tip

    If possible, avoid using spaces as part of IIS directory names. Officially, spaces are illegal characters in URLs and must be replaced with an escape code. The escape code for a space is %20. Although most current browsers will replace spaces with %20 for you, earlier versions of browsers might not, and won’t be able to access the page.

  5. The new folder inherits the default file permissions of the home directory and the default IIS permissions of the Web site. For details on viewing or changing permissions, see Chapter 7, “Enhancing Web Server Security.”

    Tip

    The IIS snap-in doesn’t automatically display new folders. You might need to click the Refresh button on the toolbar (or press F5) to display the folder.

Creating Virtual Directories

A virtual directory is a directory available to Internet users through an alias for an actual physical directory. In previous versions of IIS, you had to create the physical directory prior to assigning the virtual directory alias. In IIS 6, you can create the physical directory if one is needed when you create the virtual directory.

To create a virtual directory, follow these steps:

  1. Start the IIS snap-in, and then, in the left pane (Console Root), click the plus sign (+) next to the computer you want to work with. If the computer isn’t shown, connect to it as discussed in the “Connecting to Other Servers” section of Chapter 2.

  2. Double-click Web Sites. Right-click the Web site on which you want to create the virtual directory, choose New from the shortcut menu, and then select Virtual Directory. This starts the Virtual Directory Creation Wizard. Click Next.

    More Info

    If you want to create a virtual directory with the exact same configuration as a directory in another Web site, you can create the virtual directory from a metabase configuration file. Create a backup of the virtual directory configuration as discussed in the section entitled “Creating IIS Backup Configurations” in Chapter 16. Then restore the configuration using a new alias as discussed in the section of Chapter 16 entitled “Restoring Virtual Directory Configurations.”

  3. In the Alias text box, type the name you want to use to access the virtual directory. As with directory names, the best alias names are short but descriptive. Click Next.

  4. Set the path to the physical directory where your content is stored. Type the directory path or click Browse to search for a directory. The directory must be created before you can select it. If necessary, click Make New Folder in the Browse For Folder dialog box to create the directory before you select it. However, don’t forget about checking and setting permissions at the operating system level as discussed in Chapter 7.

  5. Set access permissions for the virtual directory. Normally, you’ll want to set Read and Run Scripts permissions only. The standard permissions are these:

    • Read Allows users to read documents, such as HTML files

    • Run Scripts Allows users to run scripts, such as ASP files or Perl scripts

    • Execute Allows users to execute programs, such as ISAPI applications or CGI executable files

    • Write Allows users to upload files to the site, such as with FrontPage

    • Browse Allows users to view a list of files if they enter the name of a valid directory that doesn’t have a default document

  6. Click Next and then click Finish. The virtual directory is created.

    Note

    A virtual directory that is created as an application is indicated with an icon that shows an assembly cog. If, however, the virtual directory is part of the default application pool, the virtual directory is indicated with an icon that shows a globe. For more information on pooled applications, see Chapter 6, “Managing ASP.NET, Application Pools, and Worker Processes.”

Modifying Directory Properties

You can modify the settings for a physical or virtual directory at any time. You set directory permissions and general directory properties in Windows Explorer. You set IIS permissions and properties in the directory properties dialog box. In the IIS snap-in, right-click the directory and then select Properties.

Renaming Directories

You can rename physical and virtual directories in the IIS snap-in. When you rename a physical directory, the actual folder name of the directory is changed. When you rename a virtual directory, the alias to the directory is changed. The name of the related physical directory isn’t changed.

To rename a physical directory, follow these steps:

  1. In the IIS snap-in, click the plus sign (+) next to the Web site you want to work with.

  2. Right-click the directory you want to rename and select Rename from the shortcut menu. The directory name is selected for editing.

  3. Edit the name of the folder and then press Enter.

    Caution

    Browsers store file and directory paths in bookmarks. When you change a directory name, you invalidate any URL that references the directory in its path string. Because of this, renaming a directory might cause a return visitor to experience the 404 File Or Directory Not Found error. To resolve this problem, you might want to redirect browser requests to the new location using the technique discussed in the “Redirecting Browser Requests” section of Chapter 4.

In previous versions of IIS, you could rename virtual directories by right-clicking the virtual directory in the IIS snap-in and selecting Rename. In IIS 6, you can no longer rename virtual directories through the IIS snap-in. The reason for this is that virtual directories are now created as applications automatically and renaming would require several instance changes in the running IIS configuration.

To rename a virtual directory, you could delete the existing virtual directory and then create a new one using the desired name. This won’t preserve the original directory settings, however. If you want to preserve the settings of the current virtual directory, you will need to perform the following steps:

  1. Create a backup of the virtual directory configuration as discussed in the section entitled “Creating IIS Configuration Backups” in Chapter 16.

  2. Restore the virtual directory with a new alias as discussed in the section of Chapter 16 entitled “Restoring Virtual Directory Configurations.”

Deleting Directories

You can delete physical and virtual directories in the IIS snap-in. When you delete a physical directory, the directory and its contents are removed and placed in the Recycle Bin. When you delete a virtual directory, only the alias to the directory is removed. The actual contents of the related physical directory aren’t changed.

To delete a physical or virtual directory in the IIS snap-in, follow these steps:

  1. In the IIS snap-in, click the plus sign (+) next to the Web site you want to work with.

  2. Right-click the directory you want to delete and select Delete from the shortcut menu. When asked to confirm the action, click Yes.




Microsoft IIS 6.0Administrator's Consultant
Microsoft IIS 6.0Administrator's Consultant
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 116

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net