How Do I Enable Apache File and Directory Indexing in Linux or UNIX?

There are two ways to enable Apache file and directory indexing – 

I) Using Apache config file – 

1. You can add directory options in the Apache configuration file directly.
httpd.conf is an Apache config file, or you can add it in /etc/apache2/apache2.conf:

# vi /etc/apache2/apache2.conf

<Directory /var/www/>

Options Indexes FollowSymLinks


2. Once you add the code mentioned above, save and close the file.

3. Restart the httpd service.

# /etc/init.d/httpd restart

II) Using .htaccess Files with Apache

If you have .htaccess enabled, you can put a config line options index in your .htaccess file.

1. Open your .htaccess file.

# vi .htaccess

2. Add the following Apache directive – 

Options Indexes

DirectoryIndex index.php index.html /example.php

3. Save and close your .htaccess file.

Was this answer helpful?

« Back