Hot-Linking and .htaccess…

Saturday, December 8th, 2007 | Tech Help

I was checking my Wordpress.com blog stats this morning and noticed that I had a new incoming link to my site. I was curious to see who and what this back-link was about. It turned out to be some guy using an image I have posted in my Diskeeper review. I have been meaning to add hot-linking protection to the site, and after a quick Google search to find a good script to add to a .htaccess file I was on my way to accomplishing my task.

Here is the script I am using(source):

1. RewriteEngine On
2. RewriteCond %{HTTP_REFERER} !^$
3. RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?mysite.com [NC]
4. RewriteRule \.(jpeg|jpg|gif|png)$ http://mysite.com/pathtoimage/badhotlinker.jpg [NC,R,L]

The code above filters out image requests based on the site that sent the request, so only my site is able to display images from my domain, and it only affects images with the following extensions: jpeg, jpg, gif, or png. It also replaces the hot-linked image with an image of my choice (badhotlinker.jpg)

Next I had to come up with an image to display instead of the hot linked image. I thought about just using Paint to create something quick and easy but instead decided upon Goatsie as my image of choice. Below is the image and .htaccess file in action on the offending site (BEWARE: NSFW). Unfortunately this image did not make his main page. You have to “read more” to see it. I have edited out the offending parts of the photo for posting here, but you should be able to get the drift of it. The hot-linker is not so lucky.

Hot-linker Meets Goatsie

Check out this site and this site for more humorous hot-linking pranks. While you are at the 2nd site I recommend checking out some of the other pranks he has pulled. Quite a funny guy.

While on the topic of Goatsie, it turns out that there is a flickr photostream of viewers 1st reaction to seeing the infamous Goatsie. Definitely makes you rethink the term “Spread ‘em!”.

Tags: ,


Search

Catagories

Photos

IMG_1395.JPG
IMG_1379.JPG
IMG_1408.JPG
IMG_1424.JPG
IMG_1435.JPG
IMG_1425.JPG

Get Spiceworks!

Free Networking Monitoring Software For Network Management