Apache web server: Mapping a URL to a local directory in Ubuntu

0 Shares
0
0
0
0
0
0
0

We would like to serve the content of a local directory to the Web through the Apache web server. The problem is that the directory isn’t into the Apache document root and we do not want to move it there. :-/
To solve this we will map a URL starting with /desired_URL to files in the /path/to/directory/ directory.
Edit the /etc/apache/sites-enabled/site-configuration-file (this file should be a symbolic link to the corresponding file in /etc/apache/sites-available/).
Add an alias of the local directory to the desired URL, e.g. map the http://www.example.com/desired_URL to the /path/to/directory/ directory.

Alias "/desired_URL/" "/path/to/directory/"

Afterwards add the following instructions for the directory:

        <Directory "/path/to/directory/">
                Options +Indexes +FollowSymLinks
                Order allow,deny
                Allow from all
        </Directory>

This will enable access to the specified directory and its symbolic links, and produce an html page with the file list of the directory. Please ensure that all directories of the /path/to/directory/ has the required execute permissions.
Sources: http://cilab.math.upatras.gr/mikeagn/content/apache-web-server-mapping-url-local-directory

Leave a Reply

Your email address will not be published. Required fields are marked *