To disable directory browsing in WordPress all you need to do is add a single line of code in your WordPress site’s .htaccess
file located in the root directory of your website.
Once connected to your website, you will find a .htaccess
file in your site’s root directory. .htaccess
is a hidden file, and if you can not find it on your server, you need to make sure that you have enabled your FTP client to show hidden files.
Now at the end of your WordPress generated code in the .htaccess
file simply add this line at the bottom:
Options All -Indexes
References
https://bloggingwizard.com/disable-directory-browsing-wordpress/
https://www.wpbeginner.com/wp-tutorials/disable-directory-browsing-wordpress/