[TIPS] Prevent Image and File Hotlinking From Your Blog

Last couple of days I found that some website was doing image and file hotlinking to my website. This will steal my bandwidth and bring fewer visitors to my blog. If this happens to you too, don’t worry. We can prevent that bandwidth theft by preventing hotlinking by adding some lines to our .htaccess file.

How do I know that my blog is being hotlinked? You can test by making a single HTML file with an image link to your blog, here is the example:

<img src="http://your-blog-name.com/image.jpg" alt=""/>

If you can see the images, then your site can be hotlinked.

So, how can I prevent image and file hotlinking? Let’s follow these steps:

1. Download your .htaccess from your site with an FTP client.

2. Open your .htaccess file.

3. Add these lines:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?yoursite.com/(.*)?$ [NC]
RewriteRule .(jpg|jpeg|png|gif)$ - [NC,F,L]

4. Save .htaccess file, and overwrite the one in your site.

5. Test it!

If you have any questions, don’t hesitate to leave any comment or PM me 🙂

Have a nice day!!