Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to disable directory indexing on Apache.

This is my .htaccess file in full. But as soon as I uncomment Options -Indexes the server falls over.

What am I doing wrong?

#Options –Indexes

<IfModule mod_expires.c>

# Turn on the Expires engine
  ExpiresActive On

# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 hour"
  ExpiresByType application/javascript    "access plus 1 hour"

# Media: images
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"

# Webfonts
  ExpiresByType application/x-font-ttf    "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>

</IfModule>
share|improve this question
1  
In what manner does the server fall over - what error messages to you see ? –  Iain Nov 18 '11 at 13:11

2 Answers 2

Probably your Apache has been configured in httpd.conf with AllowOverride set to such values it does not allow you to tune any options in .htaccess.

Do you have access to httpd.conf or Apache error log?

share|improve this answer
up vote 2 down vote accepted

In case anyone else hits the same problem, the problem was that I'd copied and pasted in the line:

Options –Indexes

And Apache couldn't cope with the encoding of the hyphen!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.