Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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?

share|improve this question
    
Have you contacted the host? They not be using Apache, so they would need to do it on the nginx side. –  Vid Luther Dec 15 '12 at 23:54
    
No, but the host states in their FAQ that you cannot use "Options" or "DirectoryIndex" in the .htaccess files for security reasons –  Freek Dec 16 '12 at 11:35

1 Answer 1

up vote 0 down vote accepted

To disable directory browsing all you have to do is drop in a blank index.html file into the wp-content\uploads 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.

share|improve this answer
    
I can still have my own .htaccess files but they can't contain "Options" or "DirectoryIndex". I've tried the plugin mentioned which adds rewrite rules to the .htaccess file. Unfortunately that gives me another Internal Server Error: IndexIgnore is not allowed here. –  Freek Dec 16 '12 at 11:27
    
Can I use IndexIgnore in the /uploads/ folder for example while adding RewriteRules so WordPress can still display my files on my website? –  Freek Dec 16 '12 at 11:34
    
Then put a blank index.html file inside the directories as I suggested. –  Wyck Dec 16 '12 at 17:08
    
Thank you, I have done that for now. I was hoping it would also be possible with RewriteRules in combination with IndexIgnore in the /uploads/ folder. –  Freek Dec 29 '12 at 20:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.