Prevent image stealing from websites
Image stealing or hotlinking of images made me irritated many times. But my hosting provider has very good option to avoid it. That make me relaxed. When i checked the details i found the way they did and it is possible for every one who is using a linux server (most of us uses linux server). Because only in linux hosting we have .htaccess file. Ok then we can think how to make it possible……
Steps
- locate your .htaccess file (if doesn’t exist please create one).
- We can protect the whole site or the certain directory from hot-linking
- For the whole site put the .htaccess file in ‘public html’ folder and for specific folders you can put in the required folder.
- Copy the below code and change the required fields as described bellow
- # Begin hotlink protection #
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourfrienddomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ yourimage_link [NC,R,L]
# End hotlink protection # - The above code give the protection to the images.
- The 2nd line is an optional one which is called the blank referrers.
Some user has a personal firewall, that deletes the page referer information sent by the web browser. Hotlink protection utilizes this information. If you don’t use that line of code you are acullay blocking these users.So It is recommended to allow blank referrers. - The third line say that it is possible to used by your own doamin and the forth line for any other site which shares your images with your permission.
- You can add any no of doamins that can possible share your images.
- Also add RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com [NC] to the code else the sharing of posts or pages will block the images.
- The last line says which all formats are protected.
- Your image link is the replacement of your images that will be visible in the hot-linked website.
- You can also put the image link as blank (-) which will shows no images in the stealer website
