How to avert files from being listed in the browser

July 8, 2024 / How-to Guide

This guide explains how to avert files from being listed in the browser. Directory listing is a feature of the Apache web server that shows the files within a directory in your browser when there is no index file present (such as index.php, index.html, index.htm, or index.js).

Follow steps-

  1. To stop the files from being listed in the browser, add the subsequent code at the top of your .htaccess file:
    Options -Indexes
  2. The .htaccess file is found within the folder of the site where you want to prevent directory listing.
  3. For instance, to disable directory listing for your primary domain on a cPanel server, you need to add the rule to the .htaccess file located here:
    /home/user/public_html/

    Note– Be sure to replace “user” with your actual cPanel username.

This was the easiest way to avert files from being listed in the browser. However, if you face any difficulty,  feel free to connect with our support specialists.

 

Spread the love