In a previous post we touched upon the Alias statement in your VirtualHost directives. An Alias is a way of defining a virtual directory for your site. This is a pretty common practice in the web world. Your site code may be stored in your site's root (wwwroot) folder, but you may want to store your assets (images, video, stylesheets, etc.) outside your webroot. You might even want to store them on another server altogether. You'll want to access these items as if they're part of your site, like http://username.companyname.loc/Images/mypic.jpg or http://username.companyname.loc/Media/myvideo.flv.
Defining an Alias is easy, when dealing with your local file system. An Alias that points to a UNC path, in Windows, is another story. You have to use a UNC path because Apache will not allow you to utilize a mapped drive (it'll crash Apache, at least under 2.0). What took me a while to figure out was that you can not use Apache to control the directory access (as in permissions), you must do this through the user account access. You can not use the Directory Apache directives for access control. This also means that your Apache instance must run as the user who has access to the remote resource (I also setup CF instance to run as the same user).
I also discovered something else the hard way, Apache Aliases are case-specific. This means that you have to use double Aliases for each virtual directory that you define via an Alias. Remember, this is Windows, so code can go either way. You'll want to plan for either eventuality.
In our last post we defined a 'sites' instance, for the display of a mythical, templated application system. So, imagine that each site of that system would require it's own VirtualHost directive. Each one, though, would also be using shared media resources from the same location outside the webroot, like on a media server. For this, you can create another include in your Apache conf folder - site_aliases.conf, within which you could singularly define your remote virtual directories:
Alias /images/ //remote-serv1/Inetpub/wwwroot/Images/
Alias /Video/ //remote-serv1/Inetpub/wwwroot/Video/
Alias /video/ //remote-serv1/Inetpub/wwwroot/Video/
Alias /Styles/ //remote-serv1/Inetpub/wwwroot/Styles/
Alias /styles/ //remote-serv1/Inetpub/wwwroot/Styles/
Alias /SiteSpecific/ //remote-serv1/Inetpub/wwwroot/SiteSpecific/
Alias /sitespecific/ //remote-serv1/Inetpub/wwwroot/SiteSpecific/
Alias /Images/ //remote-serv1/Inetpub/wwwroot/Images/
Once you've defined these remote shared resources, you can then Include them in your site definitions in your VirtualHost directives:
# Root folder for thisdomain.com, in the 'sites' instance
DocumentRoot "C:\Documents and Settings\username\My Documents\wwwroot\siteroot"
# SGB : shared Alias Include
CustomLog logs/thisdomain.loc-access.log common
# SGB : Add include for the 'sites' ColdFusion instance
Once you've restarted your Apache instance you will be able to access these resources as part of the domain.