Can Hotlinking Damage Your Google Image Search Rankings?

Date June 4, 2008

Stumble it!


$5.75 Hosting - No Committment - 559x48

There are many discussions about if hotlinking can damage your Google Image Rankings, and the answer is yes. May be you are a webmaster that don’t care about the Image Search rankings. But there are many other webmasters that have sites that depends all in image search rankings. Oh by the way, you should try the ROI in image search rankings and you will be surprised! Anyways, this is a small tutorial that will explain from 0 to the end!

Hotlink Protection Tutorial

Introduction

If you host a website, you have most likely been the victim of hotlinking at one time or another. Hotlinking is when someone displays your images (or other media) on their website by directly linking to your server. This means that they get to display your files while using your bandwidth. Luckily, it is easy to prevent with the help of the .htaccess file. This article tries to show some of the more proper methods to use to stop hotlinkers while eliminating unneeded stress on your server.

An example

Once someone found a big image on my site that they thought would make a good avatar on their forum. They linked to my server for the image, and even though it was shrunk down on the forum pages, it was still downloading the full size (over 200KB). This person had a lot of posts and it was a very heavily used forum. It ended up using about 100 Megs a day of bandwidth, or about 3 Gigs a month! That was when I decided to look into hotlink prevention.

Requirements

If you are unsure, you may have to experiment or contact your hosting service to see if they support the use of the .htaccess file. It is simply a text file which contains directives (configuration settings) for the Apache web server. It is easy to create if you do not have one already, and it is generally found in the root directory of your server. Any settings in the file will apply to all sub-directories (unless you have another .htaccess file in a sub-directory countering the effects of the main file – more on that later).

A few notes on the code

This article will cover the two main methods of hotlink prevention: Image replacement and a ‘403 forbidden’ response. You may have seen code which redirects users to a specified web page but this is not a standard use of the .htaccess file and is certainly not recommended. Basic information on the code below will be given but specifics on the flags and symbols will be left out, as it would require a much longer article. I recommend taking a look at the Apache directive documentation for more information once you get more familiar with the code.

Proper image replacement method

This method displays a specified image on the hotlinker’s page no matter what image they linked to. You can have a simple image which says “do not hotlink!” or you can use your imagination and make them really not want to hotlink to you!

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www.)?yoursite.com [NC]
RewriteRule .(gif¦jpe?g)$ /images/hotlink.$1 [L]

This code blocks all requests for gif, jpg, and jpeg files unless they are coming from either yoursite.com or www.yoursite.com. Don’t forget to change the domain name to match your own. You can also add new lines with other domain names you want to allow.

You will notice that the last line has hotlink.$1 instead of .gif or .jpg. If you truly want the .htaccess code to be proper, you must always return the correct type of image! This means you need three copies of the hotlink image for this example: one for each extension.

Proper ‘403 forbidden’ method

This method is my favorite because it is the easiest on the server and no bandwidth is used at all. Once again, there are several methods to just return ‘nothing’ but generating a 403 error for the hotlinker is perhaps the best. It will not cause any errors or confusion on your server, and the hotlinker will be left with a broken image link.

RewriteEngine on
RewriteCond %{http_referer}!^$
RewriteCond %{http_referer}!^http://(www.)?yoursite.com [NC]
rewriterule .(gif¦jpe?g)$ - [NC,F]

Just like before, you must change yoursite.com to match your domain name. You can also adjust the extensions in the last line if you wish. You do not have to worry about creating a replacement image to send though since we are just bouncing back a 403 error message.

Allow selective hotlinking

There are a couple of different ways to do this. You can of course add the domain name that you want to allow into your .htaccess file, but what about when you have certain images you want anyone to be able to hotlink to? Here is a good solution.

Create a directory on your server called ’share’ and create a new .htaccess file inside it, containing this code:

RewriteEngine off

This will counter-act the global .htaccess file, and allow hotlinking from this directory. Now you can keep your bandwidth protected while still letting certain files be hotlinked!

Post to Twitter

Want One of the Cheapest and Affordable Hosting?


$5.75 Hosting - No Committment - 559x48

What's Next?




 Subscribe To GoogleLady

 Digg It

 Save This Page

 Sphinn It

 Stumble it!

 Favorite This Post

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>