Directory listing, also known as indexing, allows web browsers to display a list of files and subdirectories within a folder when it’s accessed directly. While convenient for managing content, it can expose sensitive information for security reasons. cPanel offers functionalities within .htaccess files to enable or disable directory listing for specific directories on your website.
Enabling Directory Listing
1. Log in to your cPanel account and navigate to the “Files” section. Locate and launch the “File Manager” tool.
2. Within the File Manager, browse to the specific directory for which you want to enable directory listing.
3.1 If a .htaccess
file doesn’t exist in the directory, create a new file named exactly .htaccess
(ensure the leading dot).
3.2 If a .htaccess
file already exists, open it for editing.
4. At the beginning of the .htaccess
file, insert the following line:
Options +Indexes
5. Click the “Save Changes” button to implement the modifications and enable directory listing for the chosen directory.
Disabling Directory Listing
Follow steps 1-2 from “Enabling Directory Listing” to access the File Manager and locate the desired directory.
As described previously, create a new .htaccess
file if it doesn’t exist or open the existing one for editing.
1. At the beginning of the .htaccess
file, insert the following line:
Options -Indexes
2. Click the “Save Changes” button to implement the modifications and disable directory listing for the chosen directory.