Stop the hot-linkers
The purpose of this tutorial is to show you how to stop people using images hosted on your domain within their own websites.
You can use the information in this tutorial to force hot linked images to be redirected to another image to dub the person a lecher. This, however, does not save you bandwidth since an image is still being pulled from your server.
All of the code below goes into .htaccess on your server (this is a system file and is set to be hidden, if you can’t view it then check your FTP client settings). If you are experiencing problems with these scripts, then please insure that mod_rewrite is enabled.
Operators Dictionary:
! - Not
^ - Match the beginning of the search
$ - Match the end of the search
Bracket Dictionary:
[L] - Last (this is the last before to apply the rule)
[NC] - Not Case-sensitive (does not differentiate between upper and lower case)
[R] - Redirect (forces redirection)
The following code allows only sites from mydomain.com to use the images in the directory:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule \.(bmp|gif|jpe?g|png)$ -[F,NC,L]
Line 1 declares the ability to rewrite.
Line 2 sets it so that that if the referral is empty the rule does not apply.
Line 3 sets is so that if the referral is the domain then the rule does not apply.
Line 4 declares that any file with the extention bmp, BMP, gif, GIF, jpg, JPG, jpeg, JPEG, png, and PNG will go to an empty site.
The following code allows domains example.com and example2.com to use the image while preventing others from hotlinking:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example2.com/ [NC]
RewriteRule \.(bmp|gif|jpe?g|png)$ -[F,NC,L]
Line 1 declares the ability to rewrite.
Line 2 and 3 checks if the referral is not of the domains example.com and example2.com. If it is, then the condition is not met.
Line 4 declares that any file with the extension bmp, gif, jpg, jpeg, png, and their capitalized recipricals will go to an empty site.
The following code redirects any image hotlinked from your site to another image:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(bmp|gif|GIF|jpe?g|png)$ http://www.mydomain.com/rawr.gif [R,L]
Line 1 declares the ability to rewrite.
Line 2 checks if there is not a referral.
Line 3 checks if the referral is itself.
Line 4 declares that all extensions of bmp, gif, GIF, jpg, jpeg, and png will redirect to the image rawr.gif in the root directory.
May 29th, 2006 at 8:05 pm
Amazingly enough, I think I actually understood that
. Great tut and I’m sure I’ll be putting it to use.
May 29th, 2006 at 8:12 pm
good stuff
i knew most of it already though
May 30th, 2006 at 4:11 pm
[…] « Stop the hot-linkers […]
December 23rd, 2006 at 7:27 am
Hello!Just a testing
May 31st, 2007 at 12:52 pm
car classic sales…
Fresh information about car classic sales….
May 31st, 2007 at 12:59 pm
household credit card services…
ka-ka-sh-ka 2559828 Technologies of household credit card services…
June 4th, 2007 at 10:16 am
black cat girl…
Value information about black cat girl…
June 5th, 2007 at 12:51 am
craig huey…
craig huey co…
June 5th, 2007 at 11:44 am
doggie skins…
Good information about doggie skins….
June 5th, 2007 at 12:41 pm
spreadeagle bdsm dru berrymore…
ka-ka-sh-ka 2559828 Actual news on spreadeagle bdsm dru berrymore category….
June 6th, 2007 at 10:20 am
sexy smoking gallery…
ka-ka-sh-ka 2559828 sexy smoking gallery foundation…
June 6th, 2007 at 10:42 am
arctic monkey…
arctic monkey intro…
June 6th, 2007 at 10:53 am
starfire hentai teen titans pictures…
ka-ka-sh-ka 2559828 starfire hentai teen titans pictures info and more…
June 7th, 2007 at 11:29 am
the mack within…
the mack within intro…
June 8th, 2007 at 6:05 am
most wanted webshots wmw…
Good information source for most wanted webshots wmw….
December 6th, 2008 at 3:46 pm
unicare insurance life health individual insurance unicare health
February 22nd, 2010 at 12:26 pm
ocljlwijlmcds