Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

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.