• Dreamhost Banner Ad

How To Disable Image Hotlinking

Image hotlinking is when other people display the image hosted in your web server on their own website. That is, they directly use the image from your website, instead of downloading it and uploading it on their own server.

This is not a problem if you have plenty of bandwidth, a dedicated server and you don’t care. 🙂 However, if you are in a paid shared hosting service where every KB of bandwidth, every memory and CPU usage count, allowing image hotlinking could give your web server additional load. Your bandwidth can be consumed faster. Memory and CPU usage could be higher than normal if someone hotlinked one of your images in a high-traffic site.

Because of this, I decided to disable hotlinking of images hosted on my blog. Images will only be displayed if it is used by macuha.com. Sites hotlinking to the images will see nothing.

Here’s the code I added on my .htaccess to accomplish this task:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?macuha.com(/)?.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ - [F,NC]

If you have cPanel. this could be accomplished easily. Here’s how. I don’t have cPanel so I have to directly edit the .htaccess file.

Marhgil Macuha

Marhgil Macuha is a Computer Engineering graduate of Batangas State University. He is currently a Senior Solutions Developer at a Canadian IT company.

Facebook Comments

Leave a Reply