Forum Moderators: phranque

Message Too Old, No Replies

.htaccess - to block image hotlinking

         

djmguru

10:22 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



I want to deny access to my images folder, but still want the images to be displayed on my site. I added the below code to a .htaccess file and put it into my images folder. The only problem is that I cant view the images that are displayed on my site.

This is the code I have in my .htaccess file:

AuthName "Deny Access"
AuthType Basic
<Limit GET POST>
order allow,deny
</Limit>

oilman

10:31 pm on Oct 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's some posts on the topic to get you going:
[webmasterworld.com...]
[webmasterworld.com...]
[webmasterworld.com...] - this one's the best :)

djmguru

10:55 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



Thanks for the links, but I dont think what I want to do is considered hotlinking. I just want to block all acces to my images folder, for example, if someone types in www.mysite.com/images it will deny access. Although if someone gets on my site the images will be displayed. And if someone actually types in the whole url to a image they would be able to see it.

I hope this makes sense.

jomaxx

12:09 am on Oct 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It sounds like you're saying that people should be able to access the images, but not be able to see the list of files if they just type in the URL for the directory.

To accomplish that, just create a dummy index.html and put it in the images directory. That page will then be loaded instead of the directory list.

djmguru

1:32 am on Oct 9, 2003 (gmt 0)

10+ Year Member



That’s a good idea. Would this also keep site rippers from getting the images very easily?

jdMorgan

4:31 am on Oct 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



djmguru,

Or, you can add the line


Options -Indexes

to either your top-level .htaccess file, or to an .htaccess file in any subdirectory where you don't want to allow users to display the index. See the Apache documentation [httpd.apache.org].

Jim

plumsauce

6:44 am on Oct 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Would this also keep site rippers from getting the images very easily?

In a word no, qualified by, if the links to
the images exist on your html pages, and the
links can be navigated to, then a site ripper
that is recursively traversing the pages will
find the images.

If you then deny by agent, the site ripper can
change the agent it sends.

If you then deny by referer, the site ripper can
be sure to send you the correct referer.

+++