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

Directory listing plays a vital role in web hosting, and as a cPanel user, you have the ability to enable or disable it using .htaccess. For security purposes, web servers often disable directory listing. 

Without an index file in a directory, attempting to access it will result in a 403 HTTP Forbidden Access error, preventing clients from viewing the files. If you wish to display the files, you can enable directory listing.

To Enable Directory Listing with .htaccess

  1. Use the cPanel File Manager to create a.htaccess file. Simply name the file as .htaccess. 

If you already have the .htaccess file, locate and edit it using the cPanel File Manager.

  1. Enter or copy the following code at the beginning of the file:

Options +Indexes

  1. Save Changes and Close.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/cp_edit_htaccess_enable_dir_listing.jpg

The next time you browse the directory listing, it will display the index.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/cp_htaccess_enable_dir_listing.jpg

To Disable Directory Listing with .htaccess

  1. Create or edit the .htaccess file in cPanel File Manager.

  2. Enter or copy the following code at the beginning of the file:

Options -Indexes

  1. Save Changes and Close.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/cp_edit_htaccess_disable_dir_listing.jpg

The next time you browse the directory listing, it will display the 403 HTTP Forbidden Access error.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/cp_htaccess_disable_dir_listing.jpg

That's how you can configure the .htaccess file via cPanel to enable or disable directory listing.


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 123