Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Link Lists & Getting Listed (http://www.greenguysboard.com/board/forumdisplay.php?f=7)
-   -   How can I protect my images from beeing hotlinked? (http://www.greenguysboard.com/board/showthread.php?t=15300)

ClickBuster 2005-01-13 11:44 PM

How can I protect my images from beeing hotlinked?
 
Hey guys, I just saw some traffic coming from http://board.freeones.com, where I found a link to a gallery of mine. I believe there're also other posts, but pointing directly to the images, any suggestion how should I protect myself from hotlinking?

I can use .htaccess to protect based on the HTTP referer and if the click is not from my site it will return 404, is this good enough?

Adult Traffic 2005-01-14 12:09 AM

Yes, that's fine OR you can redirect the hotlinkers to somewhere useful.

I just use hotlink protection on a lot of my domains, some I redirect like this one:

###HOTLINKING BEGIN
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://thissite.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.thissite.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://thissite.com:80.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.thissite.com:80.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://othersite.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.othersite.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://othersite.com:80.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.othersite.com:80.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://1.2.345.678.9.*$ [NC]
RewriteRule .*[Jj][Pp][Gg]$|.*[Gg][Ii][Ff]$ http://www.someplacetoredirect404.co...MOVE/NO_NO.gif
###HOTLINKING END

cd34 2005-01-14 12:19 AM

Code:

###HOTLINKING BEGIN
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://thissite.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.thissite.com [NC]
RewriteCond %{HTTP_REFERER} !^http://othersite.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.othersite.com [NC]
!^http://1.2.345.678.9[NC]
RewriteRule .*\.([Jj][Pp][Gg]|[Gg][Ii][Ff])$ http://www.someplacetoredirect404.c...EMOVE/NO_NO.gif  [R,L]
###HOTLINKING END

First, you don't need the .*$ at the end, that requires an end of line match anchor which just wastes regexp processing. Even with your existing rules, your first rule would have also matched your third rule with the :80.*

Fewer rules = better, however, there are certain regexp rules that take more processing than chained rules.

anchored matches are always better

Adult Traffic 2005-01-14 12:26 AM

I dunno. I've run millions and millions of hits across it with no trouble.

First, mod-rewrite is voodoo. If it works like it's supposed to work, then I leave it be. I guess he could go to apache.org and write his own .. :)

I'm no Apache tech. :)

ClickBuster 2005-01-14 03:21 AM

OK here's what I've put there:

###HOTLINKING BEGIN
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.free-pussysite.com [NC]
RewriteCond %{HTTP_REFERER} !^http://free-pussysite.com [NC]
RewriteRule .*\.([Jj][Pp][Gg]|[Gg][Ii][Ff])$ http://www.free-pussysite.com/404.html [R,L]
###HOTLINKING END

It doesn't work, can you point me the errors. I'm too lazy to read mod_rewrite manual trying to figure out why it's not rewriting ;) In the same time, Apache is not returining "Internal Server Error" messages. Any ideas?

Adult Traffic 2005-01-14 08:52 AM

Quote:

Originally posted by ClickBuster
It doesn't work, can you point me the errors. I'm too lazy to read mod_rewrite manual trying to figure out why it's not rewriting ;) In the same time, Apache is not returining "Internal Server Error" messages. Any ideas?

Well, I suppose it's be just about as easy to copy what I posted there that is known to work and not modified to something different, but that's your decision I guess.

One thing, you cannot send hotlinkers like this:
RewriteRule .*\.([Jj][Pp][Gg]|[Gg][Ii][Ff])$ http://www.free-pussysite.com/404.html

You have to send them to an image, like I did. Not to a page ".html".

NOW, here's the trick. That "image" is on a different domain IN a folder with .htaccess IN the folder which redirects 404. That image does NOT exist, thus, it's a 404 image and redirected by .htaccess to a page anywhere I chose.

AST


All times are GMT -4. The time now is 02:31 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc