How to: Protect your WordPress blog from hotlinking

October 12, 2008 at 10:54 am

Hotlinking is the use of an image from one site into a web page belonging to another site. Many bloggers are hotlinked, and have their bandwidth used on another websites. Here’s a solution to protect your WordPress blog from hotlinking.

The first thing to do is to create a small image saying something like “Please do not hotlink from my server“. and upload it on your blog server.

Then, we’ll have to edit the .htaccess file, located in your WordPress blog root directory. When modifying .htaccess, always create a backup.

Append this code to your .htaccess:

RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]