Cannot disable Directory Listing in httpd.conf

Mike picture Mike · Aug 29, 2013 · Viewed 14.3k times · Source

I just installed XAMPP on my personal CentOS box and when I try to disable Directory Listing I get an Apache error when restarting. My httpd.conf file looks like this after I make the changes:

httpd.conf

Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"

<Directory "/opt/lampp/apache2/htdocs">
    Options -Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Error

XAMPP: Starting Apache...fail.
AH00526: Syntax error on line 5 of /opt/lampp/apache2/conf/httpd.conf:
Either all Options must start with + or -, or no Option may.

I have tried removing Indexes all together and I can still see my directories. Maybe I'm in the wrong file, but from what I've read disabling directory listing has to be made here or .htacces (which I am trying to avoid.) In case it comes up I have made sure to restart XAMPP every time I made changes.

Answer

covener picture covener · Aug 31, 2013

The error message is pretty clear. To rephrase / show examples:

# relative to whatever lower precedence section applies
Options -Indexes

If your goal is to turn off indexes. If you want to make sure FollowSymlinks is also set, put a + in front of it:

# relative to whatever lower precedence section applies
Options -Indexes +FollowSymlinks

If you want to turn everything but FollowSymlinks off:

# not relative
Options FollowSymlinks