Scott Forsyth's Blog

Postings on IIS, ASP.NET, SQL Server, Webfarms and general system admin.

Mastering IIS FTP - Part 2 - Virtual Directories/Physical Directories

In Part 1 we covered ways to use the hidden power of Microsoft's FTP server product.  We talked about ways to leverage virtual directories along with Windows user accounts.

Today I want to take this one step further and discuss how to work with the IIS FTP quirks with using virtual directories as . . . yes, virtual directories.  Because Microsoft has this unique way to utilizing virtual directories to offer more control, it also means that simply using virtual directories for their original purpose isn't as obvious as it should be.

Rule #3: A Virtual Directory created in IIS FTP isn't seen by a FTP program

If we want to create a virtual folder that points to a different location on a server, one of the first things we will notice is that if we create the virtual directory in IIS FTP and then use a FTP client to log in, we won't see the folder!!  We can use ChgDir if our FTP client supports it and type in the name of the vdir but that's often times not good enough.  We want to actually see it.

Let me explain it further.  Consider the following folder structure where d:\domains\mysite\ is the FTP root path:

d:\domains\mysite\
d:\domains\mysite\images\
d:\domains\mysite\bin\
d:\domains\mysite\admin\

Now, let's create a virtual directory in IIS FTP called downloads which will point to:
e:\downloads\

When we log into our FTP account, we will see images, bin and admin but we won't see downloads.

Why is that?  Since virtual directories aren't always used for their original purpose, as we saw in Part 1, they don't automatically appear.  The other reason is that FTP programs will scan the files and folders on disk to determine what to display.  Since virtual directories don't reside at the folder level, they won't be shown with the rest of the folders.

So what do we do?  Fortunately the solution is simple. 

Tip #2: Create an empty “physical” directory to have a “virtual” directory appear in a FTP program

Since the FTP client program will check for files and folders on disk, simply create an empty folder on disk where the virtual directory should show up.  In my example above, it means creating an empty folder called d:\domains\mysite\downloads\.  Now, after you log into this FTP account with your FTP program, you will see images, bin, admin and downloads.  If you double click on downloads you will be taken to e:\downloads because the virtual directory in IIS FTP will take precedence.

Rule #4: If both a Virtual Directory and Physical Directory exist, the Virtual Directory takes precedence

In my example above, I've created a “virtual“ folder which redirects to another location on the server, and a “physical“ folder so that it will show up in my FTP program.  Even if I put files in the empty downloads folder, I won't be able to access them by double clicking on the downloads folder.  Instead of being directed to d:\domains\mysite\downloads\ (physical folder) I will be directed to e:\downloads\ (virtual folder).

In summary, when creating a virtual directory that should show up in the FTP client program, make sure to create an empty physical directory to match.

In Part 1 we covered working with Virtual Directories and Windows Users.  In this Part we covered working with Virtual Directories and Physical Directories.  In Part 3 and Part 4 we will cover IIS6 User isolation (and why I don't use it) and some tricks for more advanced configurations.

Part 1 - Redirecting Users
Part 2 - Managing Virtual Directory / Physical Directories
Part 3 - The Doorway Folder Trick
Part 4 - Coming soon

Posted: Mar 10 2004, 07:30 AM by OWScott | with 16 comment(s)
Filed under:

Comments

TrackBack said:

# March 10, 2004 1:35 PM

Oddur Magnusson said:

Looking forward to your next post
# March 19, 2004 1:34 PM

TrackBack said:

# March 19, 2004 7:16 PM

Matt said:

Eagerly waiting your next articles as I am right in the middle of configuring FTP on 2003/IIS6. Curious about why you don't use User Isolation.
# March 26, 2004 4:45 PM

Scott Forsyth said:

Matt, thanks for the feedback. Sorry I've been slow on the blogs. I'm back from a week or travels next week so I'll try to get the other parts done then. To give a quick reason, it's mainly because User Isolation is built for a specific purpose (of which in my opinion caters to a very small minority of the uses) and doesn't work well with what most people are trying to do. A way around this limitation is to use a tool called linkd.exe that Microsoft provides. I discussed this by email with Oddur Snaer Magnusson who replied to my Part1 blog who gave me the linkd tip. I still find the whole process messy and revert back to the method I've blogged about but ultimately his method using linkd is a tad cleaner to the end user. I'll mention this more in my part3 or part4 blog in a couple weeks.
# April 3, 2004 6:15 PM

David Palmquist said:

Thank you so much for blogging this info. It has helped me stop from pulling my hair out this late evening.
# April 13, 2004 12:23 AM

Dan said:

I really appreciate you posting these ftp tutorials. I am anxiously awaiting your reasons for NOT using user isolation.

Thanks!
# April 13, 2004 6:44 PM

Louis Moskowitz said:

Thanks...most usefull

Louis
# April 20, 2004 9:02 AM

chris said:

i have a question.... i am running IIs server 2003. and i have web site running with domain but ftp wont acces threw domain name only ip?
when i run apache on xp ftp name works? any way to set server 2003 ftp as a domain name?

email me bak kulb @ msn.com
# May 4, 2004 3:44 PM

Scott Forsyth said:

Chris, I would double check that if you ping your domain name it resolves to the IP address correctly. FTP doesn't even see the domain name so as long as DNS is configured correctly, it will always work using either the domain name or IP address. (I'll email you too)
# May 4, 2004 3:52 PM

Gray said:

Thank you very much for your excellent insight into MS FTP! It help out loads..
# May 6, 2004 2:34 PM

Bob said:

Thanks for a very clear explanation.
# May 7, 2004 2:56 AM

Daryl said:

EXCELLENT explanation. Works just as you said. Got me out of a bind with a client. Thanks!
# June 4, 2004 12:21 PM

TrackBack said:

# February 8, 2005 6:33 PM

Civisi said:

Thanks for the information! It solved a problem I had today.  I posted my information in my blog and linked to yours.

# January 8, 2007 9:29 AM

Gonzalo said:

Great tutorial. I was trapped into IIS ftp tricky virtual folder configuration. You saved my day. Thx!

# February 8, 2007 3:08 AM