A virtual directory is a directory name, used in an address, which corresponds to a physical directory on the server. You can add a virtual directory that will include directory content in a site or an application without having to move the content physically into that site or application directory.
To add a virtual directory
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
To use the UI
Open IIS Manager. For information about opening IIS Manager, see IIS 7.0: Open IIS Manager.
In the Connections pane, expand the Sites node in the tree, and then click to select the site in which you want to create a virtual directory.
In the Actions pane, click View Virtual Directories.
On the Virtual Directories page, in the Actions pane, click Add Virtual Directory.
In the Add Virtual Directory dialog box, type a name in the Alias box. This alias is used to access the content from a URL.
In the Physical path box, type the physical path of the content folder, or click Browse to navigate through the file system to find the folder.
Optionally, click Connect as to specify credentials that have permission to access the physical path. If you do not use specific credentials, select the Application user (pass-thru authentication) option in the Connect As dialog box.
Optionally, click Test Settings to verify the settings that you specified for the virtual directory.
To add a virtual directory to the root application in a site, use the following syntax:
appcmd add vdir /app.name:string/ /path:string /physicalPath:string
The variable app.namestring is the site name and the / following the name specifies that the virtual directory should be added to the root application of the site. The variable pathstring is the virtual path of the virtual directory, such as /photos, and physicalPathstring is the physical path of the virtual directory’s content in the file system.
For example, to add a virtual directory named photos with a physical location of c:images to the root application in a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd add vdir /app.name:contoso/ /path:/photos /physicalPath:c:images
To add a virtual directory to an application other than a site’s root application, type the name of the application after / in app.namestring. For example, to add the same virtual directory used in the previous example to an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER.