Recommended MoneyMakers
moneymakers
Moola TLA DealDotCom Wikis
News
Welcome to the new and improved News Notion v3! This spot will be used to provide news and updates on News Notion and whatever is happening around here! Psst! Don't forget to subscribe to the RSS feed! --->
Subscribing options
Click the image on the left in order to subscribe to our RSS feed, or enter your e-mail address in the space below to receive regular updates via e-mail

How to Prevent Hotlinking

Posted on April 3rd, 2008 as

This weekend News Notion was forced to stay offline until I was able to receive additional bandwidth (the owner was on vacation). However, using the last few megs of bandwidth left before it was sucked up, a good friend of mine and I were able to solve the pesky little problem. He told me to search through the access logs and (after pointing me to exactly where they were located) upon opening it something caught my eye. I saw the location of my family guy picture, which I have noticed receives a few hits almost daily from people searching for it. I followed the url that accessed the image, which led me to some foreign-speaking forum, a specific thread actually.

Then, I spotted the image of Stewie I used in my post ‘10 Creative Christmas Gifts for (Almost) Anyone‘. Kind of on a guess, I checked the ‘Properties’ of the image and what do ya know? The image links directly to MINE! (Disclaimer: It’s not really my picture of Stewie, but I uploaded and used it. I do not own Family Guy, or specifically Stewie)

Now, how to deal with a hotlinker? Well, it took some investigation, because I have never dealt with one before. Surprisingly, all it takes is a simple code insert into your .htaccess file, found in the public_html directory. I recommend inserting the code now rather than waiting until you realize you have been hotlinked and there goes all your bandwidth!

Insert this code into your .htaccess file to prevent being hotlinked:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]

This’ll give a 403 Error to anyone trying to link to an image other than yourself linking to an image from your own site. Replace ‘yoursite’ with well, your site, and if it’s not a .com, replace it with the correct TLD. Just don’t get rid of the slashes or anything.

After adding this little code and updating the file, go to your site and make sure everything is working. One thing my friend and I tried to do looked fine at first. But, all the internal links weren’t working! So, make sure to check everything out before giving it the OK. Then, for the final test, use this Hotlink Protection Checker to see if the code works! Make sure to clear your cache and refresh first.

And that’ s it! Your hotlinking problems will be over!

I would like to thank Bush Mackel for helping me out this past week with all these tech problems going on and for being so freakin’ awesome! Also thanks to Swollen Pickles’ post ‘How to Prevent Hotlinking and Bandwidth Theft‘ for the code I needed to stop this mess!

Comments

Trackbacks

  1. The Best of the Blogosphere: April 4, 2008 | Super Blogging
Post a comment:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word