How to Restrict Directory Listing in cPanel

August 11, 2023 / cPanel & WHM

In this article, we have explained how to restrict directory listing in cPanel.

Follow the steps-

  1. Log in to cPanel.
  2. Select the “Advanced” category and click on the “Indexes” sub-option.
    advanced
  3. Once on the new page, find the “public_html” folder.
  4. Click on the “Edit” button.
    edit
  5. Set indexing as “No Indexing” and click on the “Save” button.
    no indexing
  6. Disabling the directory indexing will be accomplished and you will receive a notification as shown below.
    indexes
  7. You also have the option to upload an empty “index.html” or “index.php” file if you prefer not to display any content on your website while still preventing directory listing.
  8. Alternatively, you can enhance your website’s configuration by including specific code lines in your “.htaccess” file.
  9. The following lines will define which file serves as the initial page of your website. Just remember to substitute the newpage.html with your index file name.
    #Alternate default index page
    DirectoryIndex newpage.html

That’s it! This was the easiest way to restrict directory listing in cPanel. For more information, contact our technical experts. Also, do not forget to check our latest web hosting plans.

Spread the love