Prevent Image Linking Using .htaccess
Here is how to make sure other sites don’t link to your images from their site using a .htaccess file (I’ve had reports of this not working perfectly):
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www.)?yourdomain.com/.*$ [NC]
RewriteRule .(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]You need to hard-code your domain name into this one. This .htaccess file may need to be in your images directory to work. I’ve used a 302 (temporary) code above instead of a 301 (permanent).
📄 Download a PDF of This Article
