Anti-Hotlinker Mod Rewrite Script
April 21st, 2007 by mescalito
If you have apache mod-rewrite installed on your server you can use this script to stop people from hot-linking your images. Consult your sys admin if you’re not sure if you have mod rewrite or not.
Put this script inside your .htaccess file. It will protect everything in this directory and below.
AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_REFERER} !^http://.*yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://XX.XX.XX.XX/.*$ [NC]
RewriteRule .*[Jj][Pp][Gg]$|.*[Gg][Ii][Ff]$ http://www.yourdomain.com/ [R,L]
The yourdomain and XX.XX.XX.XX should be replaced with any domains and ip addresses that are allowed access. You should always include the ip address of your domain into this script.





















