Control the privacy and security of your website by managing directory listings through the .htaccess file in cPanel. Whether you’re a website owner or a developer, this guide provides simple steps to enable or disable directory listings, offering tailored control over your site’s security settings. Let’s explore how to efficiently manage directory listings for enhanced website privacy.
To enable Directory Listing, you must use .htaccess
If your system doesn’t have the .htaccess file or if you’re unable to locate the file, follow the below steps. Else skip to step 11
Step 1: Login to cPanel
Step 2 : Go to Files ➝ File Manager
Step 3: Click on the public_html folder on the left sidebar
Step 4: A collection of files and directories will be displayed in this space.
Step 5: If you can’t find the .htaccess file here go to Settings on the top right of the File Manager
Step 6: In the Preference window that pops up, mark the Show Hidden Files(dotfiles) option and click on Save
Step 7: If you still don’t see the file click on File on the top left of the File Manager
Step 8: Enter .htaccess as the filename in the New File Name textbox.
Step 9: Enter a directory where you want to place the .htaccess file in the below section. The directory section is preconfigured to have “public_html” as the default selection.
Step 10: Now click on Create a New File
Step 11: Right-click on the .htaccess file and click on Edit
Step 12: If you don’t want to select any Character Encoding option, just click on the Edit button the window that pops up.
Step 13: Enter/copy this code at the beginning of the file:
Options +Indexes
Step 14: Click on Save Changes
Your next search to find the directories will show the index.
To Disable Directory Listing with .htaccess
Step 1: Create or edit the .htaccess file within the cPanel File Manager.
Step 2: Copy or paste this code at the top of the page:
Options -Indexes
Step 3: Now, click Save Changes and Close.
The next time you search for the directories listing, show an error message stating 403 HTTP forbidden Access message.
This is how you modify the .htaccess file through cPanel to disable or enable directory listing.