Directory listing allows visitors to see all files in a directory when no index file is present. By default, web servers disable this feature for security reasons, showing a 403 Forbidden error instead. Using .htaccess in cPanel, you can easily enable or disable directory listing for specific directories on your web hosting account.

How to Enable Directory Listing

  1. Step 1: Create or locate the .htaccess file

    Use the cPanel File Manager to create a .htaccess file in the directory where you want to enable listing. If the file already exists, locate and open it for editing.

  2. Step 2: Add the enable directive

    Enter or copy the following code at the beginning of the file:

    Options +Indexes
  3. Step 3: Save the changes

    Click Save Changes and close the editor.

    Editing .htaccess to enable directory listing

  4. Step 4: Verify the result

    Browse to the directory in your web browser. You should now see an index listing of all files and subdirectories.

    Directory listing enabled

How to Disable Directory Listing

  1. Step 1: Create or locate the .htaccess file

    Use the cPanel File Manager to create or edit the .htaccess file in the directory where you want to disable listing.

  2. Step 2: Add the disable directive

    Enter or copy the following code at the beginning of the file:

    Options -Indexes
  3. Step 3: Save the changes

    Click Save Changes and close the editor.

    Editing .htaccess to disable directory listing

  4. Step 4: Verify the result

    Browse to the directory in your web browser. You should now see a 403 Forbidden error instead of the file listing.

    Directory listing disabled - 403 error