If you got a camera to improve your posts (like I wrote in Five things all bloggers need) then you will sooner or later find a jerk or two that’s stealing your work and using it on their own blog/web site. As a blogger you need to protect the content you’ve worked so hard for and you need protect your bandwidth from bandwidth theft. Unfortunately it’s not always so easy, but to protect your pictures from “hotlinkers” (people using content hosted by you as their own without giving you credits) there’s an easy to use way to make their life a little bit harder.
If you’re site is hosted on a Un*x server you can use something called .htaccess to make hotlinking almost impossible. I used this method when Xavier Media had a free Midi file archive at www.xaviermedia.com/midi/ so I know that it’s working
Create a text file called .htaccess.txt using Notes or Wordpad:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?sampleaddress.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/prohibited.jpe [L]
The first line turns the Rewrite Engine so this example will work, the second line will allow your own domain name to link to your pictures and the third line will allow empty referrals. [NC] on the second line means No Case and is used when you need SaMPleAddreSS.com to be the same thing as sampleaddress.com
In the fourth line you set the file extensions you want to rewrite and the image to display instead of the hotlinked images. Please note that the prohibited image is called .jpe instead of .jpeg so it will show in the visitors browser (otherwise you create an infinite loop which will case no image at all to show up
).
If you know the domain names of some bad guys hotlinking to your valuable stuff on your server you can use this code in your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+.)?facebook.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?blogspot.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?myspace.com/ [NC]
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/prohibited.jpe [L]
You can block as many domain names you like. Just make sure you add [NC,OR] at the end of each line except for the last RewriteCond line which should only have [NC] at the end.
When you’ve saved your work simply upload the file to your server (the www directory or maybe the directory where you keep your pictures). If you called your .htaccess file .htaccess.txt you need to rename it to .htaccess when you have uploaded the file to your server.
If you got other files you need to protect this example works with any other file type. I mentioned in the beginning of this post that I used it on midi files 