Apache can display a directory’s file list when no recognised index page exists. This guide explains how to disable that listing through a website’s .htaccess file.

Disable directory listing

  1. Back up the existing .htaccess file.

  2. Open the file in the directory you want to protect. For a typical cPanel primary website it is /home/exampleuser/public_html/.htaccess; use your actual document root and username.

  3. Add this directive without removing existing application rules:

    Options -Indexes
  4. Save and test a directory URL that has no index page.

Apache must permit this directive in .htaccess. If the site returns a server error, restore the backup and ask the administrator to check the configuration.

Disabling the listing does not prevent direct access to a known file URL. Use appropriate authentication or access rules for private files.