How to disable directory listing with .htaccess
By default, Apache web servers will display the file contents of any directory that does not include an index file. For example, if your directory does not contain an index.html, index.php, or similar index file, Apache will display the folder contents for all to see.
This is bad for security and can let anyone view your sensitive files.
The easiest way to prevent directory indexing is to disable it in .htaccess.
Simply open your .htaccess file, or create a new file called .htaccess in your website root folder if you don’t have one.
Enter the following line and save the file:
# Disable Directory Indexing Options -Indexes
Now when trying to view the same files, you’ll see a 403 forbidden message.