Hotlink Protection
Enabling Hotlink Protection
(flash tutorial)
Hot linking is probable one of the most popular ways for users to steal bandwidth and copyrighted material from other webmasters. Basically anything that someone links to, that resides on another user's web hosting account is considered hot linking. Users also call it Leeching. This can be anything from images to files.
Most users do not understand that if something is posted on the Internet, weather it's legally copyrighted or not, it's considered covered. This means if I were to post an image on this site, something I created, and someone else linked to it from their site, it would be in violation and I could seek legal action if I choose to. This is considered hot linking and there are ways to protect a site and file from it happening.
Hot linking is a large bandwidth consumer also. Many users do not realize how bandwidth really works. So here is a simple run down of how it works.
Bandwidth Example
Let's say we have an image that is 1MB is file size. Let's also say that the site it's hosted on receives somewhere around 100 hits a day, and each hit downloads this 1MB file.
1MB X 100 Hits = 100MB
So the site would consume 100MB a day in bandwidth. That's 3,000MB or around 3Gigs a month in bandwidth.
Now let's say that another site is linking to the same image and they also receive around 100 hits a day, and each one of those hits downloads the 1MB file.
So now we have two sites downloading the same file and at the same amount of times. This would mean we would take our total bandwidth consumption for the day and times it by two.
100MB a day X 100MB a day = 200MB a day
So now we have 200MB being used a day and only 100MB is actually being used by the account. So that would double the total monthly bandwidth. Now the site isn't using 3Gigs a month, it's using 6Gigs. There is a large difference in bandwidth and the account owner has to pay for the other site using their resources.
Consider this as being a small example. Most sites have more images or files and there will normally be more then just one site linking to them. A good way to figure out who's linking to your images and files is to dig through the web stats. Web statistics can return allot of good information about a site and how users utilize it.
cPanel has done a very good job a setting up a nice little system that will help prevent other sites and users from linking to images, files, or pretty much anything that doesn't need to be linked to from another place other then the main site. The system works with mod_rewrite, so check with your hosting provider to be sure that this is available.
Note: If mod_rewrite isn't available then this option in cPanel cannot be used.
Settings
There are a few settings that a user can set before setting up hotlink protection through cPanel. The first thing a user will see is weather or not hotlink protection is active or inactive.

click image for better view
Next there is a box to type in URLs to allow access to this account. This is for allow certain sites access and also sub-domains within the account. There are a few things to keep in mind when setting up access URLs. First thing to consider is who will need access. Make a small list of what URLs will need access to this account. Add to that list the same URLs but without the www in front of them. Yes there is a difference in the two URLs and if one is present and the other isn't, then only the present URL will have access to the account.

click image for better view
Now we have a section that we can determine what is allowed to be linked to. This is for users that use their account to host images they post in forums or on other sites. If those image extensions are not present here, when the images are loaded on other sites it will automatically forward users to the defined URL. So be sure to decide what extensions to allow.

click image for better view
Next we have the URL to redirect users to when they've accessed a file that is protected by the Hotlink Protection script. This can be anything from a webpage to an image, anything can be used here.

click image for better view
Next in line we have the option to allow direct requests. This is for if a use types in the full location of the file in their URL bar on their browser and the extension is in the allow list.
Example: http://www.domain.com/folder/file.zip
If we had the extension “zip” in the allow list and we also had the option for direct request selected, a user would be able to download this file with no problem. If the extension is present in the allow list, but the direct request option is not set, then it would redirect the user to the redirect URL.

click image for better view
Once we've set all our settings and input everything correctly, we can click Activate. This will create mod_rewrite rules in the .htaccess file located in the root directory of the account. Do not worry as this will not overwrite the file, it will simply add the appropriate information to the bottom of the file.

Once activated, a confirmation of what was activated and the information input will be displayed.

Deactivate
Simple select Deactivate and it will remove all the entries to the .htaccess file. This will not harm the file if a user has a custom .htaccess file setup, it will simply remove what it added before. So do not worry about that, it can turned off, turned on, and edited as many times as a user would like.
