Hotlink protect files in the .htaccess and cPanel

What is HotLinking? HotLinking is when you use a url to view an image in the website code or the image url in the browser. When using url's in image code, the server does not have to use any bandwidth or http request to serve the image. Say I use a url to an image at Yahoo in my code. Yahoo's server will need to serve the image and not the server my site is on. For example, you can get the url to an image for a site like the following from yahoo:

http://l1.yimg.com/dh/ap/fp/rsz/012413/home_uni_1359057924.jpg

This can be used in your code to display the image on your website. The code looks like the following.

Why HotLink Protect your website? When people HotLink to your website, they are actually using your server resources instead of their own. When your images are HotLinked by many different people on their sites, your site can start to slow down and go under a load. Another reason is to prevent people from using your images on their site as if the image is their own. You can prevent the images from being used with HotLink protection. Lets learn how to HotLink protect through the .htaccess and through the cPanel HotLink protection feature.

Hotlink protection .htaccess code

Code can be added directly to the .htaccess to prevent HotLinking in a directory specific location. The following code is used to prevent HotLinking to jpg, jpeg, gif, png, and bmp file types.

Using the HotLink Protection in the cPanel

A feature that is included in cPanel is the HotLink Protection feature. The HotLink Protection in cPanel writes the .htaccess code for you. Below are the steps for using the HotLink Protection in cPanel.

Navigate to the security section and click the HotLink Protection icon.

To allow url's in the browser to access your images, select the "Allow direct requests" checkbox. This will let the visitor to navigate to the url in the browser while denying image linking through the code of a site.

You should see "HotLink Protection is currently enabled" on the "HotLink Protection" page.

If you open your .htaccess file, you will see the code written to the file like the snapshot to the right.