Verzeichnisindizierung auf Apache deaktivieren?

Verzeichnisindizierung auf Apache deaktivieren?

Ich möchte die Verzeichnisindizierung auf Apache deaktivieren.

Dies ist meine vollständige .htaccess-Datei. Aber sobald ich die Kommentarzeichen entferne, Options -Indexesstürzt der Server ab.

Was mache ich falsch?

#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>

Antwort1

httpd.confWahrscheinlich wurde Ihr Apache mit solchen Werten konfiguriert, AllowOverridedass Sie in .htaccess keine Optionen anpassen können.

Haben Sie Zugriff auf httpd.confunser Apache-Fehlerprotokoll?

Antwort2

Falls jemand anderes das gleiche Problem hat, das Problem war, dass ichkopiert und eingefügtin der Schlange:

Options –Indexes

Und Apache kam mit der Kodierung des Bindestrichs nicht zurecht!

verwandte Informationen