Blocking Hotlinking
I started a new site in which I'm trying to use .htaccess to block hotlinking (inserts an alternate image instead)...let's see if it works...
I started a new site in which I'm trying to use .htaccess to block hotlinking (inserts an alternate image instead)...let's see if it works...
The Webmistress posted this at 18:40 — 23rd April 2003.
She has: 5,586 posts
Joined: Feb 2001
Seems to work just fine!
Jimmy Changa posted this at 18:40 — 23rd April 2003.
They have: 220 posts
Joined: Mar 2003
hmmm, well it's at least blocked for now.
disaster-master posted this at 20:27 — 23rd April 2003.
She has: 2,154 posts
Joined: May 2001
How did you do that?
Suzanne posted this at 21:08 — 23rd April 2003.
She has: 5,507 posts
Joined: Feb 2000
RewriteEngine on
RewriteBase /path/to/directory
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://acceptabledomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.acceptabledomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://anotheracceptabledomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.anotheracceptabledomain.com/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|zip|ZIP|png|PNG|swf|SWF)$ - [F]
That will kill the image (as opposed to showing something else). In the .htaccess file. I think... HA!
Busy posted this at 22:30 — 23rd April 2003.
He has: 6,151 posts
Joined: May 2001
or smaller:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?webaddress.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.webaddress.com/stolen_image.gif [R,L]
and just make an image called 'stolen_image.gif' that can be anything (smaller the better in file size) that will display instead of other images. can say 'hot linking is a crime', 'now auto forwarding to porn site', 'this image hotlinked from ...', 'umm you've been naughty - go stand in the corner' ... or can just be a blank image (transparent gif)
disaster-master posted this at 22:34 — 23rd April 2003.
She has: 2,154 posts
Joined: May 2001
YAY!! It works.
Thanks Suzanne and thanks T for bringing this subject up. I have been having major problems with people hotlinking images from me.
Sonia
LOL@busy
I think I will try doing an image.
When I discovered my hotlinkers, I did an image that said,
"SHAME ON ME!!
I am hotlinking this image from
someone elses site and and using
their bandwidth for my own good."
And I just named my "shame" image the same name as what they had stolen. Had to do about 8 of them which was time consuming.
I can't tell you what the first one I made said.
It was satisfying to see my "replacement" where their
stolen image was.
Jimmy Changa posted this at 03:49 — 24th April 2003.
They have: 220 posts
Joined: Mar 2003
I used that shorter version for my site, but for some reason the alternate image isn't showing up. Hmmm.
medic119 posted this at 18:48 — 24th April 2003.
They have: 5 posts
Joined: Apr 2003
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www\.)?domain.net/.*$ [NC]
RewriteRule \.(gif|jpg|zip|png|swf)$ http://www.domain.net/hotlink/thief.jpg [R,L]
It blocks, but does not feed the new image out to the page.
Also I know this allows direct requests from the address bar, but should it allow the image from a page made thusly? I figured it should block it. I am running the test page from my local Harddrive and not the server.
<html>
<head>
</head>
<body>
<h1>Test Page for Hotlinking</h1>
<img src="http://www.domain.net/images/a303.jpg">
</body>
</html>
Jimmy Changa posted this at 21:26 — 24th April 2003.
They have: 220 posts
Joined: Mar 2003
There!!! Finally!!!
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?myscans.com(/).*$ [NC]
RewriteRule .*\.(jpg|jpeg)$ http://www.myscans.com/hotlinked.gif [R,NC]
Be sure to make the swapped image to be of a different type you are blocking. For my site, it's the jpgs that I want blocked...so I made hotlinked.gif .
medic119 posted this at 22:05 — 24th April 2003.
They have: 5 posts
Joined: Apr 2003
I had wondered about that.
In my inital attempts a friend told me to use
RewriteCond %{REQUEST_URI} !^/thief\.jpg
and that should tell it to block all images except that one, but it didn't work.
Just curious, why not?
Jimmy Changa posted this at 14:32 — 25th April 2003.
They have: 220 posts
Joined: Mar 2003
I'm not sure. All I know is it works now, yeah! lol
disaster-master posted this at 17:01 — 25th April 2003.
She has: 2,154 posts
Joined: May 2001
I found this Htaccess Disable Hotlinking Code Generator that generated the code below. It works too!!
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com(/).*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?seconddomain.com(/).*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|jpeg|swf)$ http://www.yourdomain.com/images/hotlinker.gif [R,NC]
P.S. Hey DOC (medic119)!!
Jimmy Changa posted this at 18:07 — 25th April 2003.
They have: 220 posts
Joined: Mar 2003
^^cool
BTW medic, Love that image.
justjeni posted this at 04:05 — 26th April 2003.
They have: 59 posts
Joined: Apr 2003
That is great!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.