Denying access to a directory with htaccess


#1

I’m trying to deny access to a directory using htaccess. After reading on the net i think i have the code correct, but all it does is give Internal Server Errors. Someone on another forum said the code should work

Here’s what i’m using

[quote]<Files .htaccess>
order allow,deny
deny from all

<Directory “scripts”>
Order Deny,Allow
Deny from All

ErrorDocument 403 /403.php
ErrorDocument 404 /404.php[/quote]
Here’s what the error log gives

[quote][Tue May 05 03:41:42 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:41:42 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:41:54 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:41:54 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:42:09 2009] [error] [client hidden] client denied by server configuration: /home/calona/calona/.htaccess
[Tue May 05 03:42:09 2009] [error] [client hidden] File does not exist: /home/calona/calona/403.php
[Tue May 05 03:42:33 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:42:33 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:42:36 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here
[Tue May 05 03:42:36 2009] [alert] [client hidden] /home/calona/calona/.htaccess: <Directory not allowed here[/quote]
Anyone know what’s wrong?


#2

The error log is telling you what is wrong! You can’t use the Directory clause in an .htaccess file. You would know that if you read the documentation: http://httpd.apache.org/docs/

Since .htaccess files are “per-directory configuration files” just place the relevant directives in an .htaccess file inside the directory you want to deny access to.

:cool: openvein.org -//-