Linking to other directories with Apache

Linking to other directories with Apache

I had a website,
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 link

A symbolic link is created using the ln command.  See man
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:

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


Apache 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

   DocumentRoot    /usr/local/www/data/freebsddiary
   ErrorLog        /var/log/apache/freebsddiary-error.log
   TransferLog     /var/log/apache/freebsddiary-access.log
   Alias           /susanalias/ /usr/home/susan/public_html/

You can see the alias definition above.  This allows
to work.

Leave a Comment

Scroll to Top