Mapping urls to filesystem locations which is not under the document root

by Ramya 2009-07-17 17:19:54

Apache server mapping filesystem locations:

There is no need for you to put all your files under htdocs. It will easy for you to have your files in any directory and access it using apache alias module. Just use the following lines to map the server to your required location.

Alias Directive:

The directives contained in this module allow for manipulation and control of URLs as requests arrive at the server. The Alias and ScriptAlias directives are used to map between URLs and filesystem paths. This allows for content which is not directly under the DocumentRoot to be served as part of the web document tree. The ScriptAlias directive has the additional effect of marking the target directory as containing only CGI scripts.

For eg if you want your url http://localhost/e/ to map to your directory E: which is not the document root,
* Open httpd.conf file.("C:/Program Files/xampp/apache/conf/httpd.conf")
* Search for the following line,
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
* After the line add your alias as,
Alias /e "E:"
* Then copy the code,
<Directory "C:/xampp/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
* Paste the code after the above and change it to,
<Directory "E:">
Options Indexes FollowSymLinks +Includes ExecCGI
Order allow,deny
Allow from all
* Now restart apache.
* Open your browser and type "http://localhost/e/". It will list all the contents inside the folder "E:"

Tagged in:


You must LOGIN to add comments