123 Reg Support

What is hotlinking and how can I stop it? (.htaccess)

This article will explain what hotlinking is and how you can prevent people from doing it to your site.

“Hotlinking”

Hotlinking, also known as ‘leeching’ and ‘bandwidth theft’, is when other people use your files directly from your site, usually without your permission. This means that each time the file is viewed through their site, you lose bandwidth.

When you have created an image or a multimedia file, you may not want people downloading your files and putting them on their own websites with little or no credit to yourself. Fortunately, there is an easy solution for all 123 Reg hosting customers.

We have the Rewrite Engine activated, which you can set up to analyse any incoming requests for files and deal with them appropriately. Using this facility is very easy, as you simply need to create an .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, as indicated by the last line.

Please note: be sure to replace ‘http://your_domain_name/’ and ‘http://www.your_domain_name/’ with your own web address.

What the code does

  • 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

You can also allow other sites to share your images by using 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]