Use Alias and Apache to Create Custom Mappings

2007 May 17
by Paul Marcotte
I really love the flexibility Apache gives you when setting up virtual hosts. Another benefit is the Alias directive. I've worked on a few concepts recently that I want to demo as a sample app. After a few revisions, I finally settled on a folder structure and Alias name setup I felt would secure my component classes and facilitate mappings to frameworks and shared libraries.Here is the folder structure (note that application names are obfuscated to protect the innocent): /apps
Here is the Apache virtual host configuration (somewahat abridged): <VirtualHost>
DocumentRoot "/path/to/apps/appName/root"
DirectoryIndex index.cfm
ErrorLog logs/appName-error_log
CustomLog logs/appName-access_log common
# application alias settings
Alias /config "/path/to/apps/appName/config"
Alias /controller "/path/to/apps/appName/controller"
Alias /layout "/path/to/apps/appName/layout"
Alias /model "/path/to/apps/appName/model"
Alias /view "/path/to/apps/appName/view"
# framework and shared library mappings
Alias /lightwire "/path/to/lightwire"
Alias /coldspring "/path/to/coldspring"
Alias /com "/path/to/com"
Alias /lib "/path/to/lib"
As you can see, using Alias within the virtual host setting provides the flexibility reconfigure applications with a change to the mapped path. So for cats who still prefer to type their objects, as I do, this is a blessing. I work in a mixed environment where the production server is IIS and dev is Apache. I hope I can create the same setup with IIS virtual directories. Anyone soing this sort of thing in IIS? Am I in for a rude awakening?