IIS with nested virtual directories
August 31, 2012 12:58 AM   Subscribe

I have a situation with aliases/virtual directories that would be easy for me to solve in Apache, but with IIS I'm jumping through some hoops. Am I on the right track, or is there a better way?

I have some URL to directory mappings on a Windows server that all follow this pattern:
/foo/download -> e:\data\foo\download
/bar/download -> e:\data\bar\download
/baz/download -> e:\data\baz\download
Now, I can't just map the whole directory "e:\data\foo" into the web server space because "e:\data\foo" can contain files that shouldn't be served via the web server. Only stuff in "e:\data\foo\download" should be available from the web server. And for historical reasons, it has to be available at "/foo/download".

I'm most familiar with Apache on Unix, and in that case I'd probably just do (adjusting for windows paths):
Alias /foo/download e:/foo/download
Alias /bar/download e:/bar/download
Alias /baz/download e:/baz/download
But this project is on Windows 2008 Server R2 SP1 with IIS. It seems like virtual directories are the way to go, but I can't create a virtual directory with an "Alias" as "foo/download" (it won't let me type the "/" in there).

So my work around is that I create virtual directories in the style of "foo-download", "bar-download", "baz-download", etc and use a URL Rewrite like such:
^([^/]+)/download(.*)$ -> {R:1}-download{R:2}
Seems to work. But am I missing something? Is there a better way?
posted by sbutler to Computers & Internet (5 answers total)
Best answer: I don't think there's anything wrong with what you have, but my default approach would be:
1) Create a virtual directory for foo, pointing to somewhere safe (c:\emptydir)
2) Underneath foo create the virtual directory for download pointing to your e:\data\foo folder

You could alternatively use the junction command to make a folder that looks the way you want (like using symlinks) but that would be harder for a random admin to work out what is going on.
posted by samj at 3:32 AM on August 31, 2012

bugger, how many times did I preview and still miss it. of course step 2 should say e:\data\foo\download
posted by samj at 3:33 AM on August 31, 2012

Response by poster: I've had thoughts along the lines of what you suggest, samj. Pros: from the management console it's immediately obvious what's happening. Cons: little work for me. Still, might go with that solution!
posted by sbutler at 12:19 PM on August 31, 2012

Response by poster: I've gone with the "map the intermediate directory to empty" solution.
posted by sbutler at 5:05 PM on September 4, 2012

Thanks for the update - I guess nobody else had a better idea!
posted by samj at 8:55 AM on September 6, 2012

« Older My long-distance best friend is depressed and...   |   Help me get the most out of my commute Newer »
This thread is closed to new comments.