Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


September 26, 2000

IIS 101: Using Virtual Directories

RSS
Subscribe to Windows Web Solutions | See More Virtual Directories Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

IIS 101

One of IIS’s best features is its ability to create and configure virtual directories. A virtual directory is a useful, easy-to-learn feature. A virtual directory isn’t an actual folder on the hard disk such as you would create with Windows Explorer; instead, a virtual directory is a name mapped to a local folder or network share. Thus, you can use the virtual directory name rather than the actual directory name to access the contents of the virtual directory.

For example, let’s say you have a Web server called Mywebserver that serves documents at D:\wwwroot\websitea. For development purposes, you’d like to have a location for posting beta versions of documents in another directory at C:\securedocuments\limitedaccess\betadocs\webdocuments. You’ve mapped the Web server to read files only from D:\wwwroot\websitea (you map servers on the Home Directory tab of the Web site’s Properties dialog box). So, how can you provide access to the beta documents from the Web server when the files you want to access are on the C drive? Virtual directories are tailor-made to solve this problem. Create a virtual directory called BetaDocs (or any other name you want), and map it to C:\securedocuments\limitedaccess\betadocs\webdocuments. Now, when you want to access the beta documents, you use the URL http://mywebserver/betadocs. The request will then deliver the default document at C:\securedocuments\limitedaccess\betadocs\webdocuments.

Thus, the URL is much less complex because you don’t need the full pathname to the files. Furthermore, you can place under one Web server information that is distributed throughout the network.

Creating Virtual Directories
Creating a virtual directory is simple. In the Internet Service Manager (ISM) Microsoft Management Console (MMC) snap-in, select the Web site that will host the virtual directory. Right-click the site, and select New, Virtual Directory to launch the Virtual Directory Creation Wizard. The wizard asks for the following information:

  • Name of the virtual directory—This name appears in the URL for accessing the virtual directory, so choose it carefully. Don’t add spaces or punctuation if you can avoid it.
  • Path—Designate the folder or share that contains the content you want to access through the virtual directory. This path can be local or on a network drive.
  • Permissions—Specify the default permissions that IIS will enforce. These permissions aren’t NTFS permissions but restrictions that IIS manages. If you use a local drive, users need NTFS permissions sufficient for reading the files.

If you specify a network share as your virtual directory source, this scenario is more complex. IIS prompts you for a username and password for accessing the share, as Figure 1 shows. When a user asks for a file from the virtual directory, IIS uses the credentials you supply here, not the account of the logged or anonymous user, to access the remote share.

IMPORTANT: Don’t use an Administrator or privileged account to access a virtual directory. If you do, you would give all users elevated privileges to the content of the virtual directory and perhaps to the server on which the content physically resides.

In addition, make sure the account you use for virtual directory authentication is valid on the server hosting the share. A common error is to use a local account on the IIS server to try to authenticate to the virtual directory. I often create a local account on both servers (i.e., the IIS server and the share host) specifically for this purpose. In this way, I don’t have a domainwide account that has access permissions, and I avoid using any other account for double duty (e.g., user authentication and virtual directory authentication). The key to this technique is giving the local account the same username and password as the account you specified when you created the virtual directory.

When you’ve created your virtual directory, you see a virtual directory icon in the IIS snap-in that looks different from your typical folder icon. The virtual directory icon that Figure 2 shows has a little globe on the folder, while a regular folder appears just like a folder in Windows Explorer.

You can control access to a virtual directory and activities that go on there. For example, a common practice is to set up an entire Web site so that it doesn’t permit any script file or executable to run except in a virtual directory that you’ve set up specifically for that purpose. In this way, you can limit security concerns to a controlled location instead of having scripts executing sitewide.

A virtual directory is a useful feature that you can use without much technical training. You can find more information in the IIS Online documentation.

End of Article



Reader Comments
Is it possible to have a virtual directory on a server outside of the Domain the IIS server is in?

Glenn March 05, 2002


I Have Created Virtual directory and i got : MSFTPSVC Event 101.

What is a problem?

Yossi July 29, 2003


If you select log visits on a virtual directroy in IIS5, where can I find the log file that is logging the visits?

thanks

Marc January 08, 2004


how i can iis and how i can access without any ip address,can u tell me about this prob ,thanx

Tahir April 28, 2004


how to send the virtual directory to the client system?
difference between the regular directory ,active directory,virtual directory?

probir May 03, 2004


I am running IIS 5.0 on Windows 2000. I have seen somesites with for example the virtual directory test at test.mydomain.com instead of mydomain.com/test. How is this done?

Eric Peterson June 13, 2004


RE: Eric Peterson

That is done via DNS and virtual servers.

Anonymous User October 28, 2004


great article, this is just what I was searching for for managing my clients sites on my local disk

Anonymous User November 06, 2004


how can i password this direcory so a web user is prompted for a user name & password?

Anonymous User January 26, 2005


Every time i select the mapped drive to use as my virtual Directory I get a red error icon and a access denie massage.
jpino@nomadicstudio.com

Anonymous User June 02, 2005 (Article Rating: )


 See More Comments  1   2 

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Where is Microsoft NetMeeting in Windows XP?

...


IIS and Web Administration Whitepapers Best Practices for SharePoint Backup & Recovery

Meeting Compliance Objectives in SharePoint

Improve SharePoint Performance for Remote Workers

Related Events Check out our list of Free Email Newsletters!

IIS and Web Administration eBooks Web Filtering: An Assessment

Keeping Your Business Safe from Attack: Monitoring and Managing Your Network Security

Related IIS and Web Administration Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement