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

Hotlinking"Or known as the 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 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 we do not host images and images can be downloaded to another website outside the scope stealthsetting.com. In this case we will do next.

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 can not be retrieved directly from the source link stealthsettings.com, and the site will take pictures will display the image oops.gif Host to laurentiu.us.

Here's a real case. A "IT Blog"Thought to help people ignorant 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: // (. RewriteCond% {HTTP_REFERER} ^ http: // (. +.)? Softpedia.com/ [NC] RewriteRule. *. (Jpe? G | gif | bmp | png) $ http://laurentiu.us/oops.gif [IT]

In the situation above all sites can take pictures on stealthsettings.com (or website for that edition. Htaccess) with the exception of names from 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.

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

About the author

Stealth LP

Founder and editor Stealth SettingsIn 2006 date.
Experience on Linux operating systems (especially CentOS), Mac OS X, Windows XP> Windows 10 and WordPress (CMS).

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment is processed.