Protect your WordPress blog from hotlinking

October 20, 2008 · Print This Article

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]

Your choice for site templates and wordpress themes


Got something to say?

You must be logged in to post a comment.