I am coming from IIS and setting up virtual directories there is so pleasantly easy. You just right-click and add a "virtual directory" pointing to any path you like. This relative path gets reflected through the browser when viewing the site.
How do I accomplish the same thing with Apache? Symlinks scare me because deleting cascades through. Is there a better way to create virtual directories in Apache? I am using MAMP for Mac which uses apache2.
Use the
Alias
directive in the Apache configuration file.Additionally,
rm -r
does not traverse symlinks and will not cascade through.If you point multiple domains to the same public html directory, and the actual content resides outside of the public html (web root), you can do this in two steps:
1) rewrite the directory per domain, e.g.
2) Then add symlinks (alternatively, the Alias)
Just be careful. host_two images can be accessed via host_one: domain_one.ca/images/host_two/{filename}
Unless you add additional rules that anything NOT in the current host directory be remove. For the host_one VirtualHost (I did not confirm whether this rule works):
If it's a Secure Server the 'Alias' directory needs to go to in the VirtualHost 443 config as well