Protect all files in a directory from direct access?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Protect all files in a directory from direct access?

Post by tomfra »

Is it possible to allow only the "home" domain name to access files in a given directory? In other words, I do not want other people, spiders, etc. to be able to access images and other files that should be used by the web pages on my domain only.

Thanks!

Tomas
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

OK, I've found a way using RewriteRule, but is it possible to disallow accessing specific file name(s) instead of just the file type?

Tomas
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

if you are running apache, look at .htaccess
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

Yes, I do know that this can be done via .htaccess and I found a way how to protect any file type I specify, but what about a specific file? I am sure it's mentioned somewhere at http://httpd.apache.org/docs/misc/rewriteguide.html but I couldn't find it there.

Tomas
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

http://httpd.apache.org/docs-2.0/mod/mod_access.html is what you really should look for ;)
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

It doesn't seem to solve my, albeit specific, problem. I'll try it via PHP...

Thanks for the ideas!

Tomas
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

you probably have configured your webserver wrong... Because following works fine..

Code: Select all

<Directory "C:/private">
 Order deny,allow
 Deny from all
 Allow from .home
</Directory>
Post Reply