Stop Hotlinking by .htaccess (How to setup Hotlink Protection in .htaccess)

"Hotlinking”Or also known as leeching, piggy-backing, directly linking, offsite image grabs is a method by which a web page takes images other websites. The more large images and multiple visits on the site that took images is even more traffic and consume more banda (Bandwidth) On the source server. Of course, this applies not only to files. You can retrieve files .mp3And files video lesson and even archives. In these last three cases banda consumption would be much higher and would automatically bring extra costs to the host server.

How can we block other sites to take pictures of our source?

To do the following scenario. We stealthsettings.com image host and we do not want the images to be retrieved on another web page outside the domain stealthsetting.com. In this case we will do the following.

1. Add a file .htaccess in webrootThe site that are hosted images.

2. In. Htaccess add the following lines.

RewriteEngine On
RewriteCond% {HTTP_REFERER}! Http: // (. +.)?stealthsettings.com / [NC]
RewriteCond% {HTTP_REFERER}! ^ $
RewriteRule. *. (Jpe? G | gif | bmp | png) $ http://laurentiu.us/oops.gif [L]

This means that files with extensions . Jpg,. Jpeg,. Gif,. Bmp si . Png cannot be retrieved with a direct link from the source  stealthsettings.com, and the site that will take the images will display the image oops.gif Host to laurentiu.us.

Here is a real case. A "IT BlogHe thought of helping ignorant people stealing tutorials from us. With all sources. The new lines added. Htaccess had the following effect on the site that took images:

Do not know - we teach you

How can we block specific sites to take pictures.

May be other situations in which you want to allow taking images from other websites except some.

RewriteEngine On
RewriteCond% {HTTP_REFERER} ^ http: // (. +.)? Facebook.com/ [NC, OR]
RewriteCond% {HTTP_REFERER} ^ http: // (. +.)? Hi5.com/ [NC, OR]
RewriteCond% {HTTP_REFERER} ^ http: // (. +.)? Softpedia.com/ [NC]
RewriteRule. *. (Jpe? G | gif | bmp | png) $ http://laurentiu.us/oops.gif [L]

In the above situation all sites can take pictures from stealthsettings.com (or from the site for which we edit .htaccess) except for the domains and subdomains of facebook.com, hi5.com si softpedia.com. Images taken from these three areas will be redirected to laurentiu.us / oops.gif.

* Specify as to use The module mod_rewrite must be present in the apache webserver.

Founder and editor Stealth Settings, from 2006 to the present. Experience on operating systems Linux (in particular CentOS), Mac OS X, Windows XP> Windows 10 si WordPress (CMS).

How to » Linux » Apache » Stop Hotlinking by .htaccess (How to setup Hotlink Protection in .htaccess)
Leave a Comment