Hotlinking is when another web site owner links directly to one or more of your images or multimedia files and includes it on their web page.

Hotlinking is when other people use your files directly pulled from your site, meaning each time the file is viewed through their site, it comes out of your Bandwidth, in the end this means that you could end up paying for the bandwidth.

On Linux servers there is an easy solution. They have to have the Rewrite Engine activated. This means that you can set it up to analyze any incoming request for a file and deal with them appropriately.

Do the following;
Create a .htaccess file, then add the following code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain_name/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain_name/.*$ [NC] [OR]
RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg)$ - [F]

This will only allow your sites to display your images and multimedia files. The Code Explained

  1. RewriteEngine on
  2. RewriteCond %{HTTP_REFERER} !^$
  3. RewriteCond %{HTTP_REFERER} !^http://your_domain_name/.*$ [NC] [OR]
  4. RewriteCond %{HTTP_REFERER} !^http://www.your_domain_name/.*$ [NC] [OR]
  5. RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg)$ - [F]

Line 1 : This Turns the RewriteEngine on.
Line 2 : ^ = Begin $ = End of Line
Line 3 : Allows request from http://your_domain_name/. [NC] = Not Continue [OR] = or
Line 4 : Allows request from http://www.your_domain_name/
Line 5 : Applies the rule to specific File Formats [F] = Finish

Note: To get the | symbol, you will need to do shift + \ , normally located in the bottom left of your key board

You can also add other site that are not yours, that you wish to allow to share images, see the code below:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain_name/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain_name/.*$ [NC] [OR]
#Trusted Sites - Add Here!!!!
RewriteCond %{HTTP_REFERER} !^http://www.trusted_sites_1/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://trusted_sites_1/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.trusted_sites_2/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://trusted_sites_2/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://trusted_sites_x/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.trusted_sites_x/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg)$ - [F]

Copyright © 2000 — 2017 by The Square Eye