How do I setup hotlink protection to prevent people from stealing my images?

Posted by Daniel on August 1, 2007

Hotlinking, or Direct Linking, is a method of linking to someone else's server/website to display their images and other files. This equates to stealing bandwidth from others on the Internet. One way to prevent others from doing this to your images is by setting up a .htaccess file for hotlink protection.

To setup hotlink protection, simply create a .htaccess file in your public_html directory with the following code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?*$ [NC]
RewriteRule .(gif|jpg)$ - [F]