Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Prevent Your Site From Image Hotlinking

In this tutorial, I will explain how to prevent your site from image hotlinking. This will help you to save
your server bandwidth and cost.

What is Image Hotlnking

Image hotlink is the direct linking to your website’s image files to theft your server Bandwidth. Some people have used your site’s images directly on his website like:

When hotlinking website is loaded, then images are loaded from your website and it used your server bandwidth & costing.

How to Prevent Your Site From Image Hotlinking

You can prevent your website from image hotlinking by using the below code at the end of your htacess file.

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourdomain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpg|gif|bmp|png)$ /images/dontsteal.jpg [L]

In the above code if someone has used your site’s images, then it will be redirected to a custom image. Please keep in mind, this will also affect for search engine & RSS feeds. You can allow all the search engine and RSS feeds to access your site’s images by using below code.

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?your-site-doamin\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?google\.(.+)/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(.*\.)?google\.(.+)/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bing\.(.+)/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(.*\.)?bing\.(.+)/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yahoo\.(.+)/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(.*\.)?yahoo\.(.+)/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|png)$ /dontsteal.gif [L]

The post How to Prevent Your Site From Image Hotlinking appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

How to Prevent Your Site From Image Hotlinking

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×