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

What is the difference between document root and directory?

Besides, say there are 2 files at

C:\A\test.txt C:\B\test.txt

and the setting is like this

document root = "C:\A"; directory = "C:\B";

which file will this URL reference to ht tp://localhost/test.txt?

share|improve this question

migrated from stackoverflow.com Oct 26 '12 at 12:40

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 2 down vote accepted

DocumentRoot and Directory are used differently from one another.

From DocumentRoot:

DocumentRoot 

The directory that forms the main document tree visible from the web. This directive sets the directory from which httpd will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document. The DocumentRoot should be specified without a trailing slash.

From Directory:

Enclose a group of directives that apply only to the named file-system directory, sub-directories, and their contents.

<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. Any directive that is allowed in a directory context may be used. Directory-path is either the full path to a directory, or a wild-card string using Unix shell-style matching. In a wild-card string, ? matches any single character, and * matches any sequences of characters. You may also use [] character ranges. None of the wildcards match a `/' character, so will not match /home/user/public_html, but will match. Be careful with the directory-path arguments: They have to literally match the filesystem path which Apache uses to access the files. Directives applied to a particular will not apply to files accessed from that same directory via a different path, such as via different symbolic links.

Examples of each type can be found on the Apache2 documentation links above.

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.