Disable Apache directory listing using .htaccess
If you don’t have administrator access to the system or want to manage directory listing on a per-directory basis easily, you can use the above Options -Indexes directive in .htaccess files.
-
Open or create .htaccess file on the directory that you want to disable listing using your preferred text editor.
$ sudo vi /var/www/mysite/.htaccess
-
Add -Indexes to Options directive in the .htaccess file.
Options -Indexes
https://www.simplified.guide/apache/disable-directory-listing