Designing and Developing Database-driven Website using Cold Fusion
Application Server Technology
How to create a new virtual directory and modify its properties
Comments and any Enquiry related to this Project Welcome Here
Copyright © Abhishek Porwal, DA-IICT, Gandhinagar
Last Updated 4th September 2004

I’ve already briefly introduced the concept of virtual directories, which are a key mechanism in IIS; now I’d like to define a virtual directory a little more clearly. A virtual directory is simply a name (or alias) that points to a local folder or network share on the server. This alias is then used to access the Web application held in that physical location. For instance, imagine your company has a Web server that serves documents from C:\Inetpub\wwwroot\mySiteA. Your users can access these documents through this URL: http://www.mycompany.com/mySiteA/ you could also set up another physical location as a different virtual directory in IIS. If, for instance, you were developing another Web application, you could store the files for it in C:\dev\newSiteB. You could then create in IIS a new virtual directory called, say, Cool Pages, which maps to this location. This new site would then be accessible through this URL:
http://www.mycompany.com/CoolPages/ As this application is in development, you would probably want to set IIS to hide this virtual directory from the public until the project is complete. Your existing Website would still be visible.

Let’s create a virtual directory on your server now:

1. Right-click on Default Web Site and select Virtual Directory from the new submenu. The Virtual Directory Creation Wizard will appear. Click Next.
2. Type in an alias for your virtual directory. I’ll type in WebDocs. Click Next.
3. Browse for the directory in which your application is located. For this example,
I’m going to choose the My Pictures folder located within the My Documents directory. Click Next.
4. Set Access Permissions for your directory. Typically, you’ll want to check Read, Run scripts, and Browse. You will not need to select Write until we get into accessing the file system, discussed in Chapter 15. Click Next.
5. Click Finish.

Now, if you type http://localhost/WebDocs/ in your browser, IIS will recognize that you’re looking for a Website held in the My Pictures directory. By default, when we request a virtual directory in this way, IIS looks for an index HTML page such as index.html or default.htm. If there is no index page—in this case there isn’t—IIS assumes we want to see the contents of the requested location.

However, viewing the entire content of a location like this is not usually something we want our users to do; they could then freely see and access all the files and directories that make up our Web page. Not only is this a little messy and unprofessional, but it also can provide information to hackers that could let them attack our site. So, by default, IIS won’t allow this—we’ll receive a message reading, “Directory Listing Denied” in our browser. Bearing that in mind, there are, however, circumstances in which we do want to
Allow directory listings, so let’s see how we can enable this in IIS. First, we have to right click the virtual directory in the IIS console, and choose Properties. Then, we select the Virtual Directory tab, and check the Directory browsing box. When we click OK and open (or refresh) the same URL in our browser, we’ll see a list of all the files within the My Pictures folder.

One thing to note at this point is that we can set properties for the Default Web Site node, and choose to have them ‘propagate’ down to all the virtual directories we’ve created. So, let’s now go ahead and enable directory browsing as the default for our Web applications. Please do remember what I’ve said about the dangers of allowing directory browsing on a production Web application, and keep in mind that you should never normally allow it in a publicly accessible environment (even on an intranet). However, during development, this facility can be very handy, as it allows us to navigate and run all our virtual directories by clicking on the listing in our browser, rather than having to type in long URLs each time.

To enable directory browsing:
1. Right-click Default Web Site and select Properties. The Default Web Site Properties dialog will appear.
2. First, we need to remove the default setting which opens up the IIS help documentation for our root directory, so choose the Documents tab.
3. Select iisstart.cfml, and click Remove.
4. Now choose the Home Directory tab.
5. Check the Directory Browsing check box and select OK.
6. When the Inheritance Overrides dialog appears, click Select All and then OK. To try it out, open your browser and type http://localhost/ in the address bar. The directory listing will appear within the browser

As you create Web applications, you’ll only need to select the directory that the Web application resides in to launch your work, but do remember to disable directory browsing should you later make your IIS Web server publicly visible.


PREFACE
ACKNOWLEDGEMENTS
CONTENTS
My Home Page
Reliance
My Home Page
Hosted by www.Geocities.ws

1