Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to deny access to directory /foo/secret.

If I create a .htaccess file in /foo/secret, with...

<Directory ./>
        Order deny,Allow
        Deny from all

...I get a "500 Internal Server Error", which, while achieving the intended result, isn't the "403 Forbidden" message I was expecting.

I know you're supposed to put an absolute path in Directory directives but I'm committing this into a code repository and the remote client won't necessarily be running in the same path.

share|improve this question
up vote 3 down vote accepted

Don't add <Directory ./> directive. .htaccess points to the directory itself. At least, that worked for me...

share|improve this answer
Perfect. Looks like my apache skills are rusty... thanks! – Julian H. Lam Apr 15 '11 at 18:22
Don't give up! Practice makes perfect. P.S. Why not mask the answer as correct? ;) – HUB Apr 15 '11 at 18:41
Why HUB, you just answered so quickly, Superuser wouldn't let me mark it as correct! :) – Julian H. Lam Apr 22 '11 at 23:43

.htaccess files are already in a directory, so that directive is non-applicable. Just skip it and go straight to your directives.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.