Htaccess Disable Hotlinking Code Generator

* note - this will not work on a windows system

If people are 'hotlinking' to your image files, they are using your bandwidth which you will ultimately pay for.

You can stop this from happening by placing a '.htaccess' file in the folder where your images are stored. This will only allow requests from your own pages to display the images - anyone linking to them from outside of your website, or any website you choose, will have the 'red x' instead of the image.

Use the following form to create the code to place into your htaccess file to stop people hotlinking your images/files. The code uses mod_rewrite.

Enter the urls which you want to allow to link to your images/files. This would normally be the site where the images are stored, however you may have several websites which you would like to allow to use your images.

If you put the htaccess file in the domain root folder, ie http://www.yourdomain.com, this will affect every folder under it.

If you have subdomains that link to the images, you will need to add the subdomains in the list.

When someone hotlinks your files, you can have the link redirect to a page of your choosing. The front page of your site is a good idea! Enter the url you wish links to be redirected to.

Enter the file extensions you wish to block hotlinking on. Use lowercase, and seperate each one by a space.

Copy the generated code and paste it into notepad and save it as htaccess.txt. Upload it in ASCII format to the folder your images/files that you want to block are stored in and rename it to .htaccess (remember the dot!!)

Unless you have your ftp program set to show invisible files, the file will then disappear from sight. Don't worry, it's still there!

If you have an existing htaccess file, copy and paste the generated code into that.

All server configurations are different. What works for someone else's site might not work for yours. You have 7 different configuration options by choosing a different number at the bottom of the form. If the first one doesn't work for you, try number 2 - and so on until you find one that works.

Note: you only need to enter one style per domain,ie: http://domain.com. No need to put in http://www.domain.com, the script generates that one itself.

Note: if you use a dedicated ip, put the ip in as a domain ie: http://123.456.789.101 otherwise anyone accessing your domain through the ip won't be able to see the images

check if your images can be hotlinked

Enter the url to an image on your website. Click 'check' and a page will pop up which will either show your image, or a red 'X'. If you can see the image, your hotlink protection isn't working. If you get a red 'X', then your images can't be hotlinked.

url of image to check:

urls to allow to hotlink

url 1:

url 2:

url 3:

url 4:

url 5:

url 6:

url 7:

url 8:

blank referrers

If you have music files etc which are not accessed from a webpage, you will more than likely find there is no referrer information sent. You can set this code to block blank referrers. Bear in mind that some browsers don't carry referrer information, so this may stop a legitimate viewing of your files from your own pages. Only choose this option if this is something that you find you need.

block blank referrers

url to redirect to (if desired)

or - image to replace with (if desired) * caution!!!! Make sure the image url you enter here is NOT an image that falls under the blocked domain. This can cause a server loop, as it's trying to access an image which is blocked, which then tries to access the image again - which is blocked. Your safest bet is to rename a .jpg file to .jpe (this should still work) and don't put the .jpe extension in your list of blocked image extensions.

files to block

Seperate with spaces. No 'dots' needed.Remember...if blocking jpg files, include jpeg.Add as many file types as you wish.

1

2

3

4

If you find that your images don't get blocked, choose another number above and generate the file again for a slightly different configuration.