Problems w/ .htaccess (preventing hotlinking)
Posted by: daisygirl
Posted on: 2005-03-14 10:57:00
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?
Edited by daisygirl on 03/14/05 10:58 AM (server time).