tags:

views:

465

answers:

1

I am looking for the specific .htaccess command that will allow me to deny http access from everyone BUT my scripts.

I have a script that runs out of the root directory that goes and fetches all of the .jpg's out of a given protected directory with the following .htaccess file

<files *.jpg>
    order allow, deny
    deny from all
</files>

I was thinking something similar to this might work

<files *.jpg>
  order allow, deny
  deny from all
  allow from rootUrl.com
</files>
A: 

Your first example should work, since scripts don't make any HTTP requests.

Edit: Unless, your script for some strange reason makes HTTP requests to its own server, which I really don't think it does. Nor should it.

Edit again: Since your script is outputting img elements pointing to the protected files, you have to let all visitors access the files. There is no work-around. You could however stop hotlinking by using .htaccess like this:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ [F]
You
Well my script goes through and posts a link to the picture and basiclaly displays <img src='path/to/file/picture.jpg'> The script works for all other directories except the protected one...
Derleek
Well, that's not your script accessing them. It's still the visitor's browser accessing them.
You