Skip to main content

Directory Aliases in Apache HTTPD server

By October 3, 2013October 10th, 2016No Comments

Directory AliasesExisting in life would be nice sometimes if you could just get on an use software, services. If it would just work! Alas, we exist knowing that life and certainly our IT life is not like this and often we need to make the little adjustments. In this tutorial we are going to look at using Directory Aliases in the Apache HTTPD. Learning how to make our Web Server more friendly and amenable.

Why We Need Directory Aliases

Taking the example of an installation server, we may want the web server to be an installation server for Linux but, it may not be practical or desirable to have the install file under the document root. In the demo the installation files are located in the folder /install/11-4 and my DocumentRoot is /srv/www/htdocs. So never the twain shall meet: unless! …. we use directory aliases. Directory alias are used to map between URLS entered in the browser to filesystem paths. Creating an alias on the installation server enables the URL: http://servername/oss114 to map to the directory located at /install/11-4 and solving my problem.


Directory Aliases are just part of the normal HTTPD server configuration and can be in the httpd.conf or an included file, such as, /etc/httpd/conf.d/directory.conf . Informing the server that for and incoming URL we must redirect to elsewhere in the file system. The example that we use in on an Apache 2.2 Server but this is equally used on Apache 2.4.

#alias URL FileSystemPath
alias /os114/ /install/11-4/
<Directory /install/11-4>
 Options +Indexes

Viewing the above code where we first define the alias os114, allowing access to this as http://servername/os114 . Using the alias we would be directed to the /install/11-4 directory.  All we need is the alias line but we have also added in a directory block describing how we may set up options for the target directory. Enabling the alias to function the server must load the module mod_alias; however, often this is loaded as standard as it is used for access to the documentation if it is installed.