Is your bandwidth meter spinning like a top, but your page views just aren’t where you think they should be for all that “traffic”? It’s possible that you, my friend, are a victim of bandwidth theft due to hotlinking. Hotlinkers are dirty SOBs who steal your bandwidth by streaming your graphics, videos and/or music files onto their web site(s) directly from yours. Luckily daddy has a relatively simple solution to fix all the badness for you.
While there are a few options you have when you want to deal with hotlinkers, I’m going to demonstrate the easiest and often best suited solution: displaying an alternate graphic instead of the one that the hotlinkers are stealing from your web site. If you’d like more options or want to do something different feel free to leave a comment below and I’ll answer as best as I can.
Now for the fun stuff. In the root of your blog’s web space, find and download (or create, if necessary) the .htaccess file. After you have a local version, copy and paste the following (and we’ll get into why some of the text is in bold in a moment) into the very beginning of the file:
If you don’t copy+paste the text above into the beginning of your .htaccess file you may run into problems if you break something that already exists, so please use caution. Also, don’t let all the mumbo-jumbo scare you off. It’s pretty simple stuff. In fact, there are only six lines, and I’ll walk you through what each one does.
-
# HOTLINK STOPPERThis line is just a comment (delineated by the # at the beginning of the line) to let you know what this section of your
.htaccessfile is for. You can comment out any line by prepending it with a # symbol. -
RewriteEngine OnTurns on the rewrite engine in Apache. Without this, none of the rest of the changes are necessary. Or possible.
-
RewriteCond %{HTTP_REFERER} !^$Sets a condition for the rewrite engine to ignore anyone with a blank referer. Don’t worry about the
!^$, it’s a regular expression, or “regex”, and it works when looking for a blank referer. And yes, that’s spelled correctly… for Internet purposes, anyhow. If you’re interested in the details, read up on how a referrer came to be a referer. -
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]Sets a condition for the rewrite engine to ignore anyone that doesn’t have the domain
example\.comin their referer. Replace theexampleportion with your blog’s domain name, but make sure that if you’ve got a .org blog that you keep the backslash in from of the period, otherwise the regex will break. -
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bloglines\.com/ [NC]Sets a condition for the rewrite engine to ignore bloglines.com. This line is optional, but I kept it in this example since Bloglines is a pretty popular RSS reader, and you’re probably going to want your readers who use it to see the pictures on your server.
-
RewriteRule .*\.(jpe?g|gif)$ http://yourothersite.com/hotlink.jpg [R,NC,L]Here’s where the fun begins. This line sets up a rule that will server any graphic (in this case a .jpg or .gif file) that is not ruled out from the conditions above to the file
http://yourothersite.com/hotlink.jpg, thereby circumventing those damned, dirtyapeshotlinkers. To add more file types, just add a pipe (“|”) character aftergifand the extension (like apng) and you’re good to go.A word of caution: do not use a graphic that is on the domain that you are trying to dissuade hotlinkers from using as you’ll cause an infinite loop and in some cases may actually take down your own web server. I’ve seen it happen, and it ain’t pretty. I suggest you set up a free blog account somewhere, such as wordpress.com, and add your hotlink graphic there.
That’s pretty much it. All you have to do now is upload your new hotlink.jpg graphic and your .htaccess file and you’re good to go. If you’ve done everything right then the days of your bandwidth being stolen by hotlinkers should be coming to a close.

