How to block hotlinking to my Joomla image files?

Hotlinking is a way to take images or other files and embed them directly into a website that doesn't own those files. In other words, it is an unauthorized use of someone else's bandwidth. 

When hotlinking is detected and you need to serve some unexpected alternate content, add the following code to your .htaccess file. This will protect all files of the types included in the last line (add more types if needed):

# stop hotlinking and serve alternate content
<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{HTTP_REFERER} !^$ 
RewriteCond %{HTTP_REFERER} !^http://(www.)?domain.com/.*$ [NC] 
RewriteRule .*.(gif|jpg)$ http://www.domain.com/donotsteal.jpg [R,NC,L]
</ifModule>

To deliver a standard (or custom, if configured) error page instead of some yucky, but funny image, replace the line containing the RewriteRule in the .htaccess directive with the following line:


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

To grant linking permission to a site other than yours, insert this code block after the line containing the domain.com string. Remember to replace goodsite.com with the actual site domain:

# allow linking from the following site
RewriteCond %{HTTP_REFERER} !^http://(www.)?goodsite.com/.*$ [NC]

Joomla is a powerful software that is easy to work with once you have the right host to support you. Before you lose any more time with the wrong host, check out the SiteGround Joomla hosting offer.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to test if jHackGuard is working correctly on your Joomla site?

If you want to be sure that jHackGuard is installed and working correctly on your website, you...

How to remove time stamps from Joomla SEF URLs

Due to an incorrect alias or a non-English character in your category names, Joomla may replace...

How to configure AcyMailing to comply with hostlantern e-mail terms of use?

In order to comply with the SiteGround e-mail Terms of Service you have to configure your...

Joomla caching

The caching mechanism implemented in Joomla is a way to improve the performance and loading speed...

How to extract and restore a Joomla .jpa archive or backup?

Upload your .jpa archive in public_html through your FTP client:...