Protect Your WordPress Blog From Hotlinking

by Hiroshi on November 12, 2008

in htaccess, Modrewrite, WordPress, Wp Customization

Hotlinking is the use of an image from a website into another web page belonging to another site. There is thin chances that any popular blog will not be hot linked ever. By this way other websites use your host’s bandwidth and cause load at your server which has no benefit for you but loss. Following is a solution to protect your WordPress blog from hotlinking using .htaccess file.

Ever visited a webpage when you were trying to access an image, which shows you an image saying that image stealing is prohibited. We are going to use this way. The image will still be displayed from your blog but then it can be small and of low quality minimizing load. So we will create a small image written something like “Content Stealing is prohibited at my server” and upload it on our blog server.

Then, we will edit our .htaccess file, located in your WordPress blog root directory. Sometimes ftp does not show .htaccess file because it is hidden. In that case we can apply a filter -a via ftp which will show us hidden files too.

Add the following code to your .htaccess file:

RewriteEngine On
#Replace ?myblog\.com/
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?myblog\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/donothotlink.jpg
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/donothotlink.jpg [L]

Replace myblog with your blog URL name. For this blog it will be webstylepress
Use donothotlink as a name for your jpg image.

And you are done. Now when anybody shall copy any image URL from your blog, this image will be shown instead.

Related Posts

Previous post:

Next post: