Thursday, October 2, 2008

How To Prevent Hotlinking Using .htaccess

A very easy way to prevent your gif, jpeg, png files (and any other file formats you choose) from being hotlinked in other websites is to use a few mod_rewrite rules in your .htaccess file.

  1. RewriteEngine on
  2. RewriteCond %{HTTP_REFERER} !^$
  3. RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?geekpedia\.com [NC]
  4. RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]
Ref: www.geekpedia.com