Problems w/ .htaccess (preventing hotlinking)

wordpress

#1

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.)?daisywreath.net(/)?.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?p084.ezboard.com(/)?.
$ [NC]
RewriteRule .*.(gif|jpg|jpeg|bmp)$ http://daisywreath.net/pixel.png [R,NC]

I’ve tested this, and I’m getting bizarre results. I generated the code here: http://www.htmlbasix.com/disablehotlinking.shtml 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 http://daisywreath.net/pics/ – it works, I get the 1-pixel transparant image I specified.

When I try to remotely load images from http://daisywreath.net/crochet/ 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?


#2

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 *-)


#3

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.


#4

http://httpd.apache.org/docs/howto/htaccess.html

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


#5

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!