Logo
IT Dienstleistungen

Deny Hotlinking

Bandwidth is the amount of data (information) being sent from the host server to the visitors computer. Each text letter, image, web page, and so forth is all really a bunch of data. A visitor comes to your web page, and all the data for displaying in their browser is transferred into their computer.

Bandwidth theft (or hotlinking) is when someone else’s site is linking directly to an image (or something) on your site instead of downloading the image and uploading it to their own server.

This may not sound like a problem, but in some cases it can be a big one. Imagine you made an image and 100 other sites coded THIER pages to find that image on YOUR hosted area. If it was just your page alone, the bandwidth data transfer would be very small. Now that a hundred other sites are using the image on your server, that data transfer amount has just gone through the roof. Although this may not impact your site itself, your host server will be bogged down with all this extra transferring. Thus they may make you pay more dollars for hosting and/or cut you off entirely!

This is not a solution to prevent a visitor from taking (saving) your image for use on their site. It is a prevention of linking directly to the image from your site to thiers.

Using htaccess, you can have the hotlinked image appear as a broken (not found) image or you can replace it with a new image of your own design. IMPORTANT! Before doing any of this, you have to find out from your web host if they support mod_rewrite. If it does not, the rest of this page won’t help you.

You verified that mod_rewrite is active? Good. Now organize your image files a bit so they are in one separate directory. Most people do this already and it helps for main organization anyways.

Now in the htaccess file that you save in that image directory, put this coding in…

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F] 

Replace mydomain.com with your actual domain name. That would take care of GIF and JPG files. You could add more to the coding to include MID and other file types. A broken or missing image should now appear on the other person’s site.

To add in a replacement image…

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/badimage.gif [R,L] 

As before, replace the mydomain.com with your own actual domain name and now replace the new image file location.

IMPORTANT: make sure the replacement image is not being stored inside a hotlink protected directory. it must be in an “open” directory.


Seiten-Werkzeuge