Disable Leeching of Images with mod_rewrite

You will need to create a ".htaccess" file with the below contents in your web/public_html directory to prevent leeching of images.

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yourIP/.*$ [NC]
RewriteRule .*[Jj][Pp][Gg]$|.*[Gg][Ii][Ff]$|.*[Pp][Nn][Gg]$ http://yourdomain.com/error.gif [R,L]

It prevents all images from being hotlinked and if someone tries anyway the image "error.gif" is shown. So you will also need to create a cutom "error.gif" and upload it to your main website directory.

Comment