Preventing the ‘Index Of’ page in .htaccess

When working with your site there may be many files or folders. Ideally, most folders should have an index page of some sort. For our servers, they should be one of three names: index.htm, index.html, and index.php. As long as the folder contains at least one file with one of these names, it will display on the screen.

If, however a folder does not contain one of these files, then it will simply display a list of all files and folders contained within. This is the default behavior, but you can also change it within the .htaccess file. This article will guide you on how to prevent the list showing, even if the index pages are not in the folder.

How to Prevent the Index Of page

  1. Log into your cPanel dashboard.
  2. Once in the cPanel, click on the File Manager icon, located in the Files category.
  3. Locate the .htaccess file and open it for editing.
  4. At the top of the file, add the following code:
    Options -Indexes
  5. Save and close the file.

Now when someone visits a directory or folder that has no index file, it will receive a 403 Forbidden error instead of seeing a list of the directory’s contents. The 403 error indicates the visitor does not have access permissions to view that area.

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+