The people who don’t know, a Hot-linking is when some other website uses images hosted on your site or blog. For example: a.com is your site and has some pretty nice images, then b.com decides that instead of hosting those images on their server, they can just link from their pages to the images hosted on your site a.com.
Hot-linking usually is bandwidth and of course content stealing. The b.com site will not pay for the traffic used as the image is being loaded from site a.com.
So it is a good practice to prevent images hot-linking:
You can prevent the hot-linking of your images by creating a simple code in the .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com/.*$ [NC]
RewriteRule \.(gif|jpe?g|png)$ – [F]
The above code will result in a broken image to be displayed when it is hot-linked.
The example above works for .GIF, .JPG and .PNG files, but you can add any file extension.
If you place the .htaccess file in the main folder of your site it will disable hot linking for all your site.
To block other type of files, just add their extension to the list above. For example to block movie files:
RewriteRule \.(mov|avi|wmv|mpe?g)$ – [F]
The Hot-Linking Protection is based on an Apache module called ModRewrite. So your web host should support it in order for you to be able to use these on your site.
loading...
loading...
Related posts:
- How to prevent an htaccess file from being viewed
- How to Save Disk Space on Your Server
- Importance of htaccess for Web Hosting Accounts
- How to Disable Direct Root Logins to Reduce the Security Issue?
- Trick to find a Bad bot with the help of htaccess
Posted under Webhosting
This post was written by admin on May 13, 2009
