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,587 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,152 posts
Joined: May 2001
How did you do that?
Suzanne posted this at 21:08 — 23rd April 2003.
She has: 5,512 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!
love me, love my brain :: iStockphoto portfolio
Busy posted this at 22:30 — 23rd April 2003.
He has: 6,157 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)
<?bhb if(broken){ echo("It wasn't me
"); } ?>
Learn HTML the ez way - EzHTML.net
Some people are like slinkies, they dont really serve any purpose but they still bring a smile to your face when you push them down the stairs ...
disaster-master posted this at 22:34 — 23rd April 2003.
She has: 2,152 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.
Sonia
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming -- WOW--What a Ride!!!"
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.
PlanetBurrito.com
CakeForum.com : Cake Lyrics and Discussions
UnusedDotcoms.com : Domains For Sale
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
.
PlanetBurrito.com
CakeForum.com : Cake Lyrics and Discussions
UnusedDotcoms.com : Domains For Sale
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,152 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)!!
Sonia
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming -- WOW--What a Ride!!!"
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!