Page 1 of 1

Protect all files in a directory from direct access?

Posted: Tue Dec 28, 2004 3:36 pm
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

Posted: Tue Dec 28, 2004 4:04 pm
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

Posted: Tue Dec 28, 2004 4:05 pm
by magicrobotmonkey
if you are running apache, look at .htaccess

Posted: Tue Dec 28, 2004 4:12 pm
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

Posted: Tue Dec 28, 2004 6:22 pm
by timvw
http://httpd.apache.org/docs-2.0/mod/mod_access.html is what you really should look for ;)

Posted: Tue Dec 28, 2004 8:59 pm
by tomfra
It doesn't seem to solve my, albeit specific, problem. I'll try it via PHP...

Thanks for the ideas!

Tomas

Posted: Tue Dec 28, 2004 9:47 pm
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>