Cloud Service >> Knowledgebase >> General >> How to Enable/Disable Directory Listing with .htaccess via cPanel?
submit query

Cut Hosting Costs! Submit Query Today!

How to Enable/Disable Directory Listing with .htaccess via cPanel?

In managing your website on the cloud server, maintaining security and control of directories is the most important thing. Achieving this purpose can be done through the .htaccess file, as it serves as a very powerful configuration file and aids in controlling various aspects of your web server.

In this guide, we'll go over the process of folder listing enable/disable through .htaccess file using cPanel, a widely used web hosting control panel.

Introduction to Directory Listing and .htaccess

Directory listing, otherwise known as directory browsing, can be defined as the action of visiting the contents of the directory of a given website when there is no index file (like index.html) available. This shows that the case security can be a threat because the files and directories become vulnerable to unauthorized access. Nevertheless, with .htaccess you could easily create a file for directory listing which can be prohibited.

Accessing cPanel and File Manager

Now, you'll need to access your cPanel account and navigate to the File Manager tool. Follow these steps:

  • Log in to your cPanel account using your credentials.

  • Locate and click on the "File Manager" icon within the Files section.

Editing .htaccess File

Then, go to the File Manager, and you will be able to edit the .htaccess file. undefined

File Manager will take you to the directory into which you want to enable or disable directory listing.

Tap the "+ File"button that is situated in the upper right-hand corner.

Enter `htaccess` in the "File name" text box and click on "Create New File" button.

At this point, you already have the .htaccess file prepared. Hence, you can consequently turn on or turn off directory listing according to your necessities.

Enabling Directory Listing

To enable directory listing, add the following line to your .htaccess file:

Options +Indexes

This directive tells the server to allow directory listing for the directory where the .htaccess file is located. After adding this line, save the changes to the .htaccess file.

Disabling Directory Listing

If you want to disable directory listing to enhance security, add the following line to your .htaccess file:

Options -Indexes

This directive instructs the server to disable directory listing for the directory. Remember to save the changes after adding this line to the .htaccess file.

Verifying Changes

When you are through with the edits to .htaccess file, it is crucial to check if directory listing has been enabled or disabled to your liking. You can accomplish this by using such a means as simply opening the file in your web browser. Enabled the directory listing if one appears, you should see the list of files and directories. The situation is if it is disabled you will likely receive feedback announcing that directory listings is forbidden while it is the case when it is enabled.

Final Words

To sum it up, by employing .htaccess directory listings control via cPanel on a SCSP (Server Cloud Service Provider) you increase your site’s protection level. These instructions will properly guide you on allowing or disabling listing of the public directory based on your preferences. Do make sure to remind yourself to keep your .htaccess file up-to-date at regular intervals to get the security of your website at the best level.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!