Lesson 5 | Aliases and virtual directories |
Objective | Benefits of using aliases/ virtual directories. |
Aliases and Virtual Directories
A virtual directory allows you to serve up a file or series of files from any area of the system's hard drive.
Many professionals refer to a virtual directory as an alias. From a technical standpoint, a virtual directory allows a Web server to map a URL path name (seen in the browser) to a local file (seen as you access the hard drive locally, say through a file management program) anywhere on the hard drive.
Some of the advantages of the flexible mapping of URL path names to local file names include:
Advantage | Explanation |
The ability to serve files that do not reside immediately beneath the Web server root directory | Most Web servers require that all files be located directly beneath the Web server root. However, a virtual directory allows you to include any local file or folder into the Web server directory structure, regardless of its location. You can establish a virtual directory on another system, if you wish. |
Simplified organizational structure | Instead of having to locate all files and folders beneath the Web server root, an administrator can arrange files on disk at his or her discretion. |
Cleaner URLs | Although this is a minor issue, the URL shown in the viewer's browser reflects the site's organization, enhancing the viewer's ability to navigate and enjoy the site. |
Virtual Directory
The Slide Show below is designed to show you how a virtual directory allows you to access files from any location on the hard drive.
It starts by showing you how a Web server searches for documents by default, then shows how you can implement a virtual directory solution.
- Suppose that you want your web server to present a collection of documents called doc1.html and doc2.html. They are located in the systemroot\home\sales\docs directory.
- Make this folder accessible to users under the URL https://www.anycompany.com/sales/doc1.html.
- If you do not make these folders accessible, the web servers would attempt to satisfy the web browser's request by looking for the directory \Inetpub\wwwroot\sales\docs\.
- Using a virtual directory solution, the doc1.html and doc2.html files reside in the systemroot\home\sales\docs directory and are accessed by www.yoursite/sales/docs1.html
- Using a virtual directory solution, the doc1.html and doc2.html files now reside in the systemroot\home\sales\docs directory and are accessed by the same URL