Linking to other directories with ApacheI had a website, http://test.freebsddiary.org. I had a user, susan. I wanted susan to have her website appear as a subdirectory of my main site but allow her to store her HTML files in her home directory (/usr/home/susan).
My first thought was to create a symbolic link between the main website directory and the home directory. However, there is another way: Alias.
symbolic linkA symbolic link is created using the ln command. See man ln for more information. Here’s how I create the symbolic link:
# cd /directory/of/main/web/site # ln -s /usr/home/susan/public_html/ susansym
This makes for the following URL: http://test.freebsddiary.org/susansym.
You may need to do this:
chmod o+x /usr/home/susan/
in order to get permission to display the directory contents. You will probably also have to give Apache permission to read the files. Perhaps this:
chmod o+r,o+x /usr/home/susan/public_html
aliasApache has the ability to create aliases. This alias can be global (affects all webs) or local (affects only one web). For a global alias, modify srm.conf. For a local alias, modify httpd.conf. Here’s the virtual website specifications for http://test.freebsddiary.org/:
<VirtualHost 184.108.40.206> DocumentRoot /usr/local/www/data/freebsddiary ServerName test.freebsddiary.org ErrorLog /var/log/apache/freebsddiary-error.log TransferLog /var/log/apache/freebsddiary-access.log ServerAdmin firstname.lastname@example.org Alias /susanalias/ /usr/home/susan/public_html/ </VirtualHost>
You can see the alias definition above. This allows http://test.freebsddiary.org/susanalias/ to work.