2

As I see in the httpd.conf file some codes needs these wrappers Directory, IfModule, Files, IfDefine, Location.. and some nothing. But I don't really understand what should I use where and why?

For example:

As I've seen some wrappers can have attributes like this, which should refer to /Applications/MAMP/htdocs folder only :

<Directory "/Applications/MAMP/htdocs">
    Options All
    Order allow,deny
    Allow from all
</Directory>

Unlike this:

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride All
</Directory>

This wrapper without an attribute maybe refers to all directories.

But would be good to know exactly how can I manage these modules, because it's confusing.

2 Answers 2

3

There really isn't any substitute for being aware of the manual when starting out. The directives you describe above are all part of Apache Core.

<Directory ...> </Directory> blocks apply to the named filesystem directory and it's sub directories. Your <Directory /> statement above does in fact have an attribute - / which means the whole filesystem. Note that there are rules regarding how different <Directory ...> blocks matching the same filesystem directory or part of the path interact.

<Files ... > </Files> the directives apply to the matched files e.g. deny access to files called config.php

<Files config.php>
     order allow,deny
     deny from all
</Files>

etc.

Directory directive Files directive Location directive IfModule directive IfDefine directive

2

These are called "Directives" (not wrappers) and the best place to learn about them is through the "Directive Quick Reference" (which is what everyone uses quite a bit).

http://httpd.apache.org/docs/2.2/mod/quickreference.html

<Directory />
  Options Indexes FollowSymLinks
  AllowOverride All
</Directory>

This wrapper without an attribute maybe refers to all directories.

No. This (/) refers to the top level directory of the drive that Apache is running on.

The effects of this, on the other hand, do apply to all the sub-directories of that directory unless another <Directory ...> block overrides those settings.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .