≡ Menu

Stop people from hotlinking your Blog images in WordPress.

Bandwidth is not free, so why should other people be allowed to hotlink your images to their blog ? Well, It is very easy to prevent people from hotlinking your images from your blog. All you have to do is rewrite your wordpress HTAccess file. Stoping people from hotlinking your images in non-wordpress websites should be the same in Drupal, HTML websites, other CMSes and Joomla for blocking your images from showing up at other sites not on your domain.

Here is my example of my HTACESSS file which is found in the root of my wordpress folder

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?johnsonyip\.com/wordpress [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L
]
</IfModule>
 # END WordPress

All I did was adderd the bolded lines.

Your wordpress htaccess file will look something like this if you have wordpress on your top level of your domain like www.example.com/

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/[NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L
]
</IfModule>
 # END WordPress

I also made an image called nohotlink.jpe and placed it in my images directory in my root directory of my domain at johnsonyip.com/images .

nohotlink.jpe

I learned how to do this at  http://altlab.com/htaccess_tutorial.html

Great site for learning about HTAcess mods.

1 comment… add one

Leave a Comment