Htaccess Disable Hotlinking Code Generator

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.


* note – this will not work on a windows system
* 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: otherwise anyone accessing your domain through the ip won’t be able to see the images

Scroll to Top