Problems w/ .htaccess (preventing hotlinking)

A search didn’t turn up anything about my particular issue, so I’m hoping someone can give me some advice…

I added this to the .htaccess file in my site’s root directory:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?
$ [NC]
RewriteRule .*.(gif|jpg|jpeg|bmp)$ [R,NC]

I’ve tested this, and I’m getting bizarre results. I generated the code here: and I’m using their tester to test whether it’s working or not. I cleared my cache before testing & have tested a few images in various places on my site.

When I try to remotely load images from – it works, I get the 1-pixel transparant image I specified.

When I try to remotely load images from or any of its subdirectories – the image loads anyway. I’ve cleared the cache, uploaded a random new image from my hard drive that couldn’t possibly have been in the cache, etc.

The /crochet/ directory has its own .htaccess file to specify its own 404 page and some rewrite rule whose purpose I can’t quite rember, something to do with Wordpress. Do I need to copy this info to any other .htaccess files I have in any subdirectories? I thought subdirectories inherited rules from .htaccess files in parent directories–am I wrong here?

Directories with their own htaccess won’t inherit higher level htaccess files (I think). Because if it gets conflicted rules, it’ll die =/. So you should copy/paste the code from your root file to your other htaccess file.
Thinks that’s your problem *-)

Thanks–I’ll fix that. I read on some site earlier today that it would inherit it even if there was another .htaccess file, so I was scratching my head over this. Fortunately only this directory has its own .htaccess so shouldn’t be too much hassle to keep updated separately.

You are right. But I guess if it’s only in one folder, and editing the file works, just stay with that option.

How strange that it wasn’t working, then… Changing the .htaccess in the subdirectory did fix it, though it turns out it’s a bit more work than I thought because I found a second subdirectory that also has its own .htaccess and was ignoring the one in the parent directory. Oh well, least it’s working now!