Using .htaccess to Prevent Hot Linking

Hot linking is when another website embeds an image from your website in theirs by directly linking to the image. It’s considered bad form, as every time the image is requested by a browser it’s your bandwidth being used, and bandwidth costs money.

The good news is that you can prevent hot linking by adding the following lines to your .htaccess file:

<IfModule rewrite.c>RewriteEngine OnRewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC]RewriteCond %{HTTP_REFERER} !^$RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]</IfModule>

Thanks to altlab for the .htaccess rewrite rules.