Articles on: Joomla

How to Prevent Image Hotlinking On Your Joomla Website via FTP

What is Hotlinking?



Hotlinking (inline linking) is referring to displaying an image on Website B by directly linking to that image from Website A. In this case, we can assume Website A is your website while Website B is an unknown website to you.


How Hotlinking Works and How It Affects Me?


As a website owner, you may have a number of images on your website. At the same time, someone at an unknown place may feel that they would like to apply the same images (from your website) on their own website. However, instead of saving their own copies on their website, they may insert the images via direct links to yours. This way, they will be using your bandwidth for the images and this will cost you money and loss of bandwidth.

Luckily for you, there is an easy way to prevent such cheapskate practice and we will guide you through the process of hotlink-protecting your Joomla website using the 3 steps below:

Create Your Image (for hotlinking protection)
Upload Your Image Using FTP to your Joomla site
Edit .htaccess File to Enable Hotlink Protection


Step 1: Create Your Image



This step is pretty straightforward. In this example, we are going to insert Gotcha image which will appear each time when there is a hotlinking to content on our website. If you have some development knowledge you can create an entire page, or configure your website in multiple ways to prevent hotlinking.

For convenience, just use one simple image to configure the hotlinking protection on your Joomla installation. Kindly note to save your image with an .jpe extension.

In our example, we are using hotlink-protection.jpe as seen below:



Step 2: Upload Your Image to Your Joomla Site Via FTP


After creating the hotlink-protection.jpe image, you have to upload it to the correct location of your Joomla website via FTP. In this case, we are going to upload to our Joomla subfolder since we installed Joomla in a subdirectory e.g. www.ourdomain.com/joomla

Remember, the hotlink image file should be placed inside /joomla/images folder.






After you locate the directory of your Joomla website, you need to go the .htaccess file and download it on your personal computer. From there, you can edit it with a simple text editor, such as Notepad.

AVOID USING TEXT-RICH EDITOR SUCH AS MS WORD

When you open the .htaccess file of your Joomla website for editing, you need to enter the following lines of code:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond .*\.(jpe?g|gif|bmp|png)$ /images/hotlink-protection.jpe [L]



NOTE: Where example.com is your actual domain name and you need to change that accordingly.

What this rule does is to allow the use of the images on your website, however, all requests from other websites for the specified extension types will be redirected to the hotlink-protection.jpe image that you have created in Step 1.

Updated on: 15/03/2019

Was this article helpful?

Share your feedback

Cancel

Thank you!