Disable directory browsing of uploads folder

I’m using WordPress as a CMS for a simple website.
I want to prevent users from being able to browse the directories such as the wp-content/uploads folder or any directories of my theme.

My host does not allow me to use “Options” or “DirectoryIndex” within a .htaccess file.
I have tried putting a .htaccess file in the /uploads/ folder with “IndexIgnore *” in it.
However none of my images from the /uploads/ folder will show up on my site with that option.
I also tried password protecting the directory with a .htpasswd file but this gives any visitor of my site a popup asking them to enter the credentials.

Read More

So my question is how do I prevent people from browsing the directories while enabling me to embed files from those directories in my wordpress posts/pages.

For example, can I place .htaccess file in the /uploads/ directory and add RewriteRules so WordPress can still show the files on my website?

Related posts

Leave a Reply

1 comment

  1. To disable directory browsing all you have to do is drop in a blank index.html file into the wp-contentuploads directory, each subsequent sub-directory also would need a blank index file, there are plugins that can automatically do this for you.

    ps. Get a better host, there is no reason they should disallow you having your own .htaccess files.