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:

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 with our own domain name, you can also allow other domains to link your images, as I did here, with

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

Save the file, name it .htaccess and upload it to your site’s root directory. (
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.

World Class Hosting Since 1996!