Tag Archives: htaccess block hotlinking leeching images

Mini HowTo: Using htaccess to block hot linking images

Objective: Stop another site from using your web images on their site as their own, using your server resources including bandwidth.

WARNING: Errors made in your htaccess file could cause your site to fail. You can restore operation of your web site by removing or renaming the htaccess file.

The file .htaccess (there is a dot in front of htaccess). This dot prevents the file from being viewed via a web browser.

Some htaccess files can be very advanced, this is just basic information to protect your images.

You can reference this tutorial for more information:

http://httpd.apache.org/docs/2.0/howto/htaccess.html

So, let’s get started!

open your favorite text editor, notepad for you windows users, and nano or vi for you Linux users.

Place the following into your page (taking note to replace m3server.com with our own domain name, you can also allow other domains to link your images, as I did here, with m3xs.com).

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?blamcast.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?m3server.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?m3xs.com [NC]
RewriteRule \.(jpeg|jpg|gif|png)$ – [F]

Save the file, name it .htaccess and upload it to your site’s root directory. (domain.com/.htaccess)
If you have other image extensions than the above noted, you can add those here as well.

Now, test it, make sure it works like you need it to.

- M3Server.com
World Class Hosting Since 1996!