Hotlinking, also known as deep linking, occurs when one web site links directly to graphics files on another web site.

The site which serves the images pays for the bandwidth. The site which links to the images gets free content for its users.

Many webmasters object to being hotlinked to, but hotlinking is difficult to prevent.

Preventing Hotlinking with Apache

On an Apache web server, you can use mod_rewrite and .htaccess to prevent any web page other than your own from accessing your graphic images.

Your .htaccess rule to block hotlinking will look something like this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?byteguide.com(/)?.*$ [NC]
RewriteRule .*.(gif|jpg|jpeg|bmp)$ [R,NC]

To make this process easier, html basicx maintains a code generator which will create the correct .htaccess entries to prevent hotlinking.

For more information on preventing hotlinking, read Ken Coar’s excellent article Keeping Your Images from Adorning Other Sites.