Jürgen Hohlkopf
Jürgen Hohlkopf

Reputation: 83

.htaccess Error 500 when using <Directory> because Apache

I want to use a .htaccess with to deny the access to a folder:

<Directory "/private">
    deny from all
</Directory>

But I get the following Error: /opt/lampp/htdocs/mysite/.htaccess:

I use Xampp

Upvotes: 1

Views: 715

Answers (1)

Olaf Dietsche
Olaf Dietsche

Reputation: 74078

TL;DR just place

Deny from all

without the enclosing Directory in your .htaccess file.

Because you want to restrict Deny to directory private, you must place the .htaccess file in the subdirectory private and not in the document root.


Both Directory

<Directory> and </Directory> are used to enclose a group of directives that will apply only to the named directory, sub-directories of that directory, and the files within the respective directories.

and .htaccess files

.htaccess files provide a way to make configuration changes on a per-directory basis.

serve the same purpose.

The difference between the two is just where they might be used. Directory may be used in server config and virtual host context, whereas .htaccess files are placed in the appropriate directory.

Upvotes: 1

Related Questions