cPanel's installation by default installs and enable mod_autoindex. This causes Apache to display the list of files and folders of a directory whenever DirectoryIndex files such as index.html or index.php are not present.

You can disable directory browsing in Apache for cPanel from the cPanel's dashboard.

Tutorial video:

Disable Apache directory listing in cPanel:

  1. Log in to your cPanel account.
  2. Go to Advanced section and click on Indexes.
  3. Select the web directory that you want to disable directory listing on. This is normally www or public_html.

    www is just a softlink to public_html so effectively they're both the same directory

  4. Select No indexing from the option and click on the Save button.

    What happens in the background is cPanel will append the following line to the folder's .htaccess file to disable directory listing.

    Options -Indexes

    New .htaccess file will be created if it doesn't already exist.

  5. Go back to the directory list and notice the icon on directories with directory listing disabled.
Leave a comment:
Share!