This tutorial will help you to prevent image hotlinking on Apache using .htaccess.
Prevent Image Hot Linking
Create a .htaccess file under the document root of your website. Then add the following rules to the created .htaccess file. This will block all domains except example.com from hotlink images from your site. The above in .htaccess code will prevent other domains from linking images from your website. You can also show a blocked banner in place of the hot-linked image. To show the banner use the below rules in your .htaccess file.
Disable Image Hotlinking for Specific Domains
Sometimes you may need to block image hotlinking from some specific domains. It can be any domain or subdomain name. Use the following example code in the server .htaccess file. This will block image hotlinking for the domains blockthis.com and baddomain.net.
Conclusion
In this tutorial, you have learned to prevent images to be hot linked by the unknown domains in the Apache server.