Directory listing is a crucial part of web hosting. As a cPanel user, you can enable or disable directory listing with .htaccess.
For security reasons, it is common for web servers to disable directory listing. You will get a 403 HTTP Forbidden Access error if you don’t have an index file in a directory. It does not allow the client to see the files in the directory. If you want to show these files, you have to enable the directory listing.
To Enable Directory Listing with .htaccess
1. Create a .htaccess file in the cPanel File Manager.
Just name the file as .htaccess.
If you already have the .htaccess file, find and edit the file in the cPanel File Manager.
For users who don’t know how to create/edit .htaccess file, refer to the article: How To Edit A .htaccess File Through The cPanel File Manager?
2. Enter/copy this code at the beginning of the file:
Options +Indexes
3. Click Save Changes and Close.
The next time you browse for the directory listing, it will display the index.
To Disable Directory Listing with .htaccess
1. Create/edit the .htaccess file in cPanel File Manager.
2. Enter/copy this code at the beginning of the file:
Options -Indexes
3. Click Save Changes and Close.
The next time you browse for the directory listing, it will display the 403 HTTP Forbidden Access error.
That is how you can configure the .htaccess file via cPanel to enable/disable directory listing.