Support
Web Development

How to deny external links to images from your Joomla website?

Linking to image files stored in another server is called hot linking. With this practice someone else is using the bandwidth and the storage space of your server by connecting your own images with its own website and this reduces the performance of your server.

If you think that this is happening to your website or you want to avoid it there is a way to do this. All you have to do is add the following code rules in your .htaccess file that will check whether the connection is from an unknown source and replace the desired image with an alternative error image (placeholder). As shown in the code below the .gif and .jpg image files are replaced with another image. 

#stop extrenal connection and give alternative coontent 

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www.)?example.com/.*$ [NC]
RewriteRule .*.(gif|jpg)$ https://www.example.com/alternative.jpg [R,NC,L]

Replace the address in place of example.com and the alternative image that will be shown when someone requests an image from your page in place of https://www.example.com/alternative.jpg. Also you can add other file types if desired in brackets together with the extensions (gif|jpg|.....).

Otherwise instead of an alternative image you can show an error page, simply replace the RewriteRule line in the above code with the following line:

#show an 403 forbidden error page
RewriteRule .*.(gif|jpg)$ - [F,L]

You can also give permission to another website to use your images. Place the following line of code after the line that contains the address of your page (in the above code example.com) replacing allowed.com address with the website address that you want to allow external access to your images..

#allowed website address connection
RewriteCond %{HTTP_REFERER} !^https://(www.)?allowed.com/.*$ [NC]

IPGLOBAL IKE   |  IP.GR Web Hosting and Domain Name registration services in Greece