Controlling Directory Indexing

When a visitor requests a URL that points to a folder on your server and that folder contains no index.html, index.php, or other default file, the web server must decide what to do. If directory indexing is enabled, it shows a plain list of all files in that folder. If indexing is disabled, it returns a 403 Forbidden error instead. Understanding and controlling this behaviour lets you protect sensitive files and decide exactly what visitors can see.

Show or hide file listings for folders without an index file.

Why Directory Indexing Matters

An exposed directory listing can reveal:

  • Backup files (.zip, .sql, .bak) that should never be publicly accessible
  • Configuration files accidentally placed in a web-accessible path
  • The internal structure of your application
  • Uploaded files that are not yet intended for public consumption

For most websites, directory indexing should be disabled everywhere except folders where you deliberately want a file browser (such as a public download archive).

Checking the Current State

Visit a folder URL that you know has no index file — for example https://yourdomain.com/uploads/. If you see a list of filenames, indexing is on for that directory. If you see a 403 Forbidden page, it is already off.

Disabling Directory Indexing via cPanel

cPanel provides a graphical tool for toggling indexing per directory.

  1. Log in to cPanel at clients.cyclebreezehost.com.
  2. Go to Advanced → Indexes.
  3. Use the folder tree to navigate to the directory you want to control.
  4. Click the directory name to open its settings.
  5. Select one of the four options:
OptionBehaviour
Default System SettingInherits the server-wide setting
No IndexingReturns 403 if no index file is present
Standard IndexingShows a plain filename list
Fancy IndexingShows a list with icons, file sizes, and dates
  1. Choose No Indexing to block directory listings.
  2. Click Save.

Disabling Directory Indexing via .htaccess

For more granular control — or if you prefer to keep the configuration in your project files — add directives directly to .htaccess.

Disable indexing for a specific directory

Place a .htaccess file inside the target directory (or edit the existing one) and add:

Options -Indexes

Disable indexing site-wide

Edit the .htaccess file in your public_html root:

Options -Indexes

This setting propagates to all subdirectories unless overridden by a .htaccess file deeper in the tree.

Enable indexing for one subdirectory only

To allow a listing in a specific folder while keeping indexing off everywhere else, place a .htaccess file inside that folder containing:

Options +Indexes

Blocking Access to Specific File Types

Disabling indexing prevents the directory listing but does not stop direct file access if someone guesses a filename. To block direct requests to sensitive file types, add a rule to .htaccess:

<FilesMatch "\.(sql|bak|log|env|zip)$">
    Order allow,deny
    Deny from all
</FilesMatch>

This returns 403 Forbidden for any request to files with those extensions, regardless of whether indexing is on or off.

Verifying Your Changes

  1. Open File Manager in cPanel and confirm the .htaccess file in the relevant directory contains Options -Indexes.
  2. Visit the directory URL in a browser. You should now see a 403 Forbidden page rather than a file listing.
  3. Confirm your actual website pages still load normally — the Options -Indexes directive does not affect pages served via an index file.

Common Scenarios

  • WordPress uploads folder exposed: Add Options -Indexes to public_html/wp-content/uploads/.htaccess. WordPress already creates this file with some rules; just append the line.
  • Public download section: Set Fancy Indexing via cPanel's Indexes tool on a single /downloads/ folder so users can browse available files.
  • After a migration: Newly transferred sites sometimes lack a root index.php temporarily. Disable indexing first to avoid exposing the file tree while the migration completes.

If you need help configuring access controls or have found an exposed directory on your CyclebreezeHost account, contact support at info@cyclebreezehost.com. The team is available 24/7.