.htaccess block linking to your images

02 Mar 2013

.htaccess block linking to your images

through the power of .htaccess we can prevent anyone from linking to images on your site. If someone tries to post an image from your site in their blog, you can redirect it to a new image of your choosing.

Basically this is checking if the referrer of the image is your domain, if it is not, then give them /images/youre-a-bad-boy.jpg to discourage them.

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?mikepayne.co/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images//images/youre-a-bad-boy.jpg [L]

Leave a Reply

Your email address will not be published. Required fields are marked *