How to: .HTACCESS

Do you have people hotlinking your website pictures? .HTACCESS is a way to stop them. You can do alot of things with .HTACCESS including making your own custom 404 message and sending a substitute image. For all the other things you can do, type HTACCESS in your browser and you'll see a list of sites that explain things in alot of detail. The purpose of this page is not to educate you about .HTACCESS, but rather to show you how to make a simple one that does a couple important things.

First things first. You must find out if your website is on an apache server and if they permit you to use .HTACCESS. A simple E-mail to your webspace provider will give you the answer. If the answer is no to either question, this information will not help you. Let's get right to it. open a notepad. This thing will not work if you use a page editor program or microsoft word programs. It's as easy as this. This is what mine looks like:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?greatunclebill.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?greatunclebill.com(/)?.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://greatunclebill.com/bk3.jpe [R,NC]

ErrorDocument 404 /404error.htm

Substitute your website name for greatunclebill.com in both places, lines 3 and 4.
substitute the url for your substitute picture in place of http://greatunclebill.com/bk3.jpe , line 5
and finally sustitute the url to your custom 404 page in place of /404error.htm , line 6.
Leave a space between line 5 and 6.

I must now explain a couple things. You are blocking everybody from hotlinking your gif, jpg, jpeg and bmp files. So in theory, sending them a substitute picture in it's place would not work because it too would be blocked. The trick is to make your substitute picture in a format that is unique, one - of - a - kind on your website. I have no jpe's on my website, so I did not block jpe's, thus allowing the jpe image to be substituted. And make it a big size picture so they notice it right away and stop trying to hotlink. Also, include your url on the image. You may as well get some free advertising out of the deal.

Now that you have things the way you want them, save this new notepad created file as .htaccess
If your computer saves it as htaccess.txt, don't worry.
Upload the htaccess, the substitute picture and your custom 404 page to your top or public html folder in your webspace (the same place the rest of the files go). Once the htaccess file is on the server, if it was saved as htaccess.txt, you can now rename it on the server to read .htaccess
If you have trouble getting this to work, the code should be good. The problem may be that your server likes these things in a different folder. Experiment a little or ask your provider for guidance. Good Luck !


Click the pictures to see bigger pictures. These are big files, so give them time to load.


My substitute image. Hotlinkers see this
instead of the picture they were trying to steal.

My custom 404 error page. When people type an
incorrect url or click an invalid link, they see this page.



Bill & Jackie's


Copyright © 2001 - 2005 Great Uncle Bill