Thursday, May 2, 2013

Stop "hotlinking" to your website files with htaccess file

"Hotlinking" is when somebody displays an image (or any type of file actually) on somebody else's web site directly inline on their site! There's nothing particularly wrong with that, it's a big part of how the WWW was designed to work. However, it does "steal" the bandwidth of the original site, and could possibly infringe on a copyright. To block sites from hotlinking to specific files of yours, you just need to make a .htaccess file with certain commands in it! Here's a great page with a more detailed explanation, but basically the file should look more or less like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://www.yourdomain.com/stophotlinking.html [R,NC]

Disqus Comments