Enable Directory Browsing – Apache HTTPD Server

1

Web servers always look for document index whenever the client request to view the directory, document index is nothing but a index file which will be under all the directory. Document index might be any of the following index.html,index.php,index.jsp, index.htm or custom index file, this is defined in Apache configuration file using the DocumentIndex directive. If the document index not found on the directory, you will be get an error of 404 not found or welcome page of Apache server because Apache does not allow the files to be listed when the index.html not on the directory.

This type of protection is very much required on production environment, Some time you required to list the files, allow the clients to browse content of huge public software directory; this will save your time from creating the html file to link the software. This will also help you to setup a repository for red hat network installation.

Steps

1. Remove the Welcome Page

2. Add the Virtual host.

3. Add content.

Remove Welcome Page

As i said above, Apache will display the welcome page to the clients if the document index not found on the directory. remove the welcome page by deleting the welcome page configuration file.rm -rf /etc/httpd/conf.d/welcome.conf

Add the Virtual host

Add virtual host like below, virtual host should contain the Directory directive and All Indexes directive that will allow the web server to list the files in the directory. Replace dl.itzgeek.com with your domain or ip address and also replace /var/www/dl directory.

 

<VirtualHost dl.itzgeek.com:80>ServerAdmin root@dl.itzgeek.com

ServerName dl.itzgeek.com

DocumentRoot /var/www/dl

<Directory “/var/www/dl“>

Options All Indexes FollowSymLinks

Order allow,deny

Allow from all

</Directory>

ErrorLog logs/dl.itzgeek.com-error_log

CustomLog logs/dl.itzgeek.com-access_log combined

</VirtualHost>

Add content

Put the content on directory, for the example mount your DVD of the red hat server and confirm the directory listing. Create the directory for mounting.

mkdir /var/www/dl

Mount the DVD ROM.

mount /dev/cdrom /var/www/dl

Restart the Apache server.

/etc/init.d/httpd restart

Test it by visiting the URL.

http://your.ip.add.ress

Now you could see the directories and files listed on the directory, this will list any thing that are under the directory.

You might also like

Enable Directory Browsing – Apache HTTPD Server

1