| Michael Phipps 2005-08-17, 6:01 pm |
| Hello,
I'm having problems with a rewrite rule that I'd appreciate some assistance
with.
This method of preventing hotlinking works great.
---start .htaccess
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !mysite.com [NC]
RewriteRule (.*) imgs/nohotlinking.gif
---end .htaccess
On my site I have a dynamic gallery with images stored in a database. When
people hotlink to images on my site, I intend to stamp the image with a logo
and web address, using PHP. I can do the php stuff with my eyes shut. My
problem is the rewrite rule.
For the moment I'll ignore the stamping part of my problem, and just try to
send a "no hotlinking" image to anyone linking to a dynamic image from my
gallery
Here's the best I can come up with, but I'm not having much luck.
---start .htaccess
# This lets me use /photo/thumb/3.jpg to refer to an image in my gallery
RewriteRule ^photo/thumb/(.*).jpg$ /gallery/resizejpg.php?id=$1
# using the same rewrite concept that worked earlier
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !bulletcars.c [NC]
RewriteRule (.*) imgs/nohotlinking.gif
--- end .htaccess
Now, this doesn't work, probably because the REQUEST_FILENAME doesn't
contain /photo/thumb/3.jpg. I'm guessing it contains
/gallery/resizejp.php?id=$1
Does anyone have any hints on how I can make this work?
|