How to prevent directory listing using .htaccess file?
This tutorial is about preventing your files from showing to the public on your web directory.
Here are the easy steps you can follow to restrict directory listing using .htaccess:
Step 1: Login to Cpanel.
Step 2: Click on the File Manager.
Step 3: Enter the public_html directory
Step 4: Click on the Settings button on the top right corner of File Manager. The button looks like this:
Step 5: After clicking the Settings button, tick mark on ‘Show Hidden Files (dotfiles)‘. Now, your dot hidden files will be shown including .htaccess (if any).
Step 6: Right-click on the .htaccess file and click on edit. If .htaccess file is missing you can create a new file name as ‘.htaccess’.
Step 7: Now you add the following snapshot on the top of your HTACCESS file.
This is how directory listing is prevented using the .htaccess file.