0

Is there any ways to deny users to be able to read each *.jpg images from a specific directory? from a file .htaccess

0

2 Answers 2

1

So, as I understand it from your second post, what you want is to have photos in a certain directory actually usable on certain web pages, but prevent direct access. The most direct answer is: no, you can't do that — you can't both make something available and simultaneously not available to the same user. There are, however, some things you can do:

  1. You can use Apache's rewrite rules or another advanced module in .htaccess to check the HTTP_REFERER variable and deny access if it isn't your page where you want the images to appear. This will work in many cases, but is easily subverted by a clever end user and could in some cases cause your images to not show up where you do want them (not everything passes HTTP_REFERER, for privacy reasons).
  2. Put the files somewhere outside of your web root completely, and load them programmaticly (via php or some cgi script). This gives you more flexible control, but still, there's no way for you to tell the difference between a request initiated by loading your legitimate web page and one made by someone cleverly trying to get around the block.
0
<Files ~ "\.jpg$">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>
2
  • 1
    a .htaccess shouldn't need the directory tags, it uses the directory it is placed in as the context instead. I think the directory tags here might actually cause a 500 error.
    – Sweet
    Aug 21, 2010 at 3:44
  • @Sweet Right. I didn't properly read the question.
    – Artefacto
    Aug 22, 2010 at 17:39

You must log in to answer this question.