How do I enable apache file and directory indexing under Linux or UNIX?

by on April 14, 2007 · 4 comments· LAST UPDATED April 15, 2007

in , ,

Q. I’m using Apache 2 under Linux. How do I enable apache file and directory indexing? Currently it is disabled and I would like to enable the same for /pdfs/ directory (http://domain.com/pdfs).

A. Under Apache web server automatic index generation is enabled with using Options +Indexes or Options Indexes directive.

If a URL which maps to a directory is requested, and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory.

Option # 1: Using Apache config file

Add directory option to Apache configuration file /etc/httpd/httpd.conf or /etc/apache2/apache2.conf:
# vi /etc/apache2/apache2.conf
Add following code:
<Directory /var/www/domain.com/pdfs>
Options Indexes FollowSymLinks
</Directory>

Save and close the file. Restart Apache:
# /etc/init.d/httpd restart
OR
# /etc/init.d/apache2 restart

Option #2: Using .htaccess Files with Apache

You can place config line Options Indexes in .htaccess file. Make sure .htaccess file support is enabled.
Change directory to pdfs
$ cd pdfs
Open .htaccess file
$ vi .htaccess
Append following apache directive:
Options Indexes
Save and close the file.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 LinuxFreaker October 22, 2009 at 7:37 am

Make sure .htaccess file support is enabled.

How to check if thats there in apache Distros.
What is the aim of “Using .htaccess Files with Apache”?

Reply

2 M kazzaz February 11, 2012 at 8:21 am

I did so but i still have the Forbidden Error message I can read the files but i can’t list them

Reply

3 sarah robert September 11, 2012 at 2:15 pm

I have the same problème
can you help me?
i tried with options indexes// options -indexes//options +indexes//
i have dedecated server

Reply

4 Mike Schinkel September 29, 2012 at 2:25 am

This is wrong for

.htaccess:

Options Indexes

It should be :

Options +Indexes

Reply

Leave a Comment

Tagged as:

Previous Faq:

Next Faq: