How to restrict access to wp-content, wp-includes and all sub-folders

after searching I didn't find an answer still confused of how do I hide the
-> wp-content
--> uploads
--> themes
--> plugins
-> wp-includes in browser. What I want is when viewer browse some like this: http://www.mysite.ext/wp-content they will see an error: You don't have permission to access this page.
Other said that just upload index.html or index.php with .htaccess in the folder you want to hide. But what if I have many subfolder inside wp-content I will do that every folder manually? Or there is a way either in cpanel, or in .htaccess ? Suggestion please, thanks.

Topic nofollow directory htaccess Wordpress

Category Web


Use in your .htaccess:

Options -Indexes

… to disable directory listings. See the Apache manual for details.

To restrict the access just to two URLs you might use:

RedirectMatch 204 ^/wp-content/$
RedirectMatch 204 ^/wp-content/dir/$

204 is the No Content response. Very fast. :)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.