📄 core.html.en
字号:
<p>There will be times when the server is asked to provide a document whose type cannot be determined by its <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME types</a> mappings.</p> <p>The server SHOULD inform the client of the content-type of the document. If the server is unable to determine this by normal means, it will set it to the configured <code>DefaultType</code>. For example:</p> <div class="example"><p><code> DefaultType image/gif </code></p></div> <p>would be appropriate for a directory which contained many GIF images with filenames missing the <code>.gif</code> extension.</p> <p>In cases where it can neither be determined by the server nor the administrator (e.g. a proxy), it is preferable to omit the MIME type altogether rather than provide information that may be false. This can be accomplished using</p> <div class="example"><p><code> DefaultType None </code></p></div> <p><code>DefaultType None</code> is only available in httpd-2.2.7 and later.</p> <p>Note that unlike <code class="directive"><a href="#forcetype">ForceType</a></code>, this directive only provides the default mime-type. All other mime-type definitions, including filename extensions, that might identify the media type will override this default.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="Directory" id="Directory"><Directory></a> <a name="directory" id="directory">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enclose a group of directives that apply only to thenamed file-system directory and sub-directories</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><Directory <var>directory-path</var>>... </Directory></code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr></table> <p><code class="directive"><Directory></code> and <code></Directory></code> are used to enclose a group of directives that will apply only to the named directory and sub-directories of that directory. Any directive that is allowed in a directory context may be used. <var>Directory-path</var> is either the full path to a directory, or a wild-card string using Unix shell-style matching. In a wild-card string, <code>?</code> matches any single character, and <code>*</code> matches any sequences of characters. You may also use <code>[]</code> character ranges. None of the wildcards match a `/' character, so <code><Directory /*/public_html></code> will not match <code>/home/user/public_html</code>, but <code><Directory /home/*/public_html></code> will match. Example:</p> <div class="example"><p><code> <Directory /usr/local/httpd/htdocs><br /> <span class="indent"> Options Indexes FollowSymLinks<br /> </span> </Directory> </code></p></div> <div class="note"> <p>Be careful with the <var>directory-path</var> arguments: They have to literally match the filesystem path which Apache uses to access the files. Directives applied to a particular <code><Directory></code> will not apply to files accessed from that same directory via a different path, such as via different symbolic links.</p> </div> <p><a class="glossarylink" href="../glossary.html#regex" title="see glossary">Regular expressions</a> can also be used, with the addition of the <code>~</code> character. For example:</p> <div class="example"><p><code> <Directory ~ "^/www/.*/[0-9]{3}"> </code></p></div> <p>would match directories in <code>/www/</code> that consisted of three numbers.</p> <p>If multiple (non-regular expression) <code class="directive"><Directory></code> sections match the directory (or one of its parents) containing a document, then the directives are applied in the order of shortest match first, interspersed with the directives from the <a href="#accessfilename">.htaccess</a> files. For example, with</p> <div class="example"><p><code> <Directory /><br /> <span class="indent"> AllowOverride None<br /> </span> </Directory><br /> <br /> <Directory /home/><br /> <span class="indent"> AllowOverride FileInfo<br /> </span> </Directory> </code></p></div> <p>for access to the document <code>/home/web/dir/doc.html</code> the steps are:</p> <ul> <li>Apply directive <code>AllowOverride None</code> (disabling <code>.htaccess</code> files).</li> <li>Apply directive <code>AllowOverride FileInfo</code> (for directory <code>/home</code>).</li> <li>Apply any <code>FileInfo</code> directives in <code>/home/.htaccess</code>, <code>/home/web/.htaccess</code> and <code>/home/web/dir/.htaccess</code> in that order.</li> </ul> <p>Regular expressions are not considered until after all of the normal sections have been applied. Then all of the regular expressions are tested in the order they appeared in the configuration file. For example, with</p> <div class="example"><p><code> <Directory ~ abc$><br /> <span class="indent"> # ... directives here ...<br /> </span> </Directory> </code></p></div> <p>the regular expression section won't be considered until after all normal <code class="directive"><Directory></code>s and <code>.htaccess</code> files have been applied. Then the regular expression will match on <code>/home/abc/public_html/abc</code> and the corresponding <code class="directive"><Directory></code> will be applied.</p> <p><strong>Note that the default Apache access for <code><Directory /></code> is <code>Allow from All</code>. This means that Apache will serve any file mapped from an URL. It is recommended that you change this with a block such as</strong></p> <div class="example"><p><code> <Directory /><br /> <span class="indent"> Order Deny,Allow<br /> Deny from All<br /> </span> </Directory> </code></p></div> <p><strong>and then override this for directories you <em>want</em> accessible. See the <a href="../misc/security_tips.html">Security Tips</a> page for more details.</strong></p> <p>The directory sections occur in the <code>httpd.conf</code> file. <code class="directive"><Directory></code> directives cannot nest, and cannot appear in a <code class="directive"><a href="#limit"><Limit></a></code> or <code class="directive"><a href="#limitexcept"><LimitExcept></a></code> section.</p><h3>See also</h3><ul><li><a href="../sections.html">How <Directory>, <Location> and <Files> sections work</a> for an explanation of how these different sections are combined when a request is received</li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="DirectoryMatch" id="DirectoryMatch"><DirectoryMatch></a> <a name="directorymatch" id="directorymatch">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enclose directives that apply tofile-system directories matching a regular expression and theirsubdirectories</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><DirectoryMatch <var>regex</var>>... </DirectoryMatch></code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr></table> <p><code class="directive"><DirectoryMatch></code> and <code></DirectoryMatch></code> are used to enclose a group of directives which will apply only to the named directory and sub-directories of that directory, the same as <code class="directive"><a href="#directory"><Directory></a></code>. However, it takes as an argument a <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>. For example:</p> <div class="example"><p><code> <DirectoryMatch "^/www/(.+/)?[0-9]{3}"> </code></p></div> <p>would match directories in <code>/www/</code> that consisted of three numbers.</p><h3>See also</h3><ul><li><code class="directive"><a href="#directory"><Directory></a></code> fora description of how regular expressions are mixed in with normal<code class="directive"><Directory></code>s</li><li><a href="../sections.html">How <Directory>, <Location> and<Files> sections work</a> for an explanation of how these differentsections are combined when a request is received</li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="DocumentRoot" id="DocumentRoot">DocumentRoot</a> <a name="documentroot" id="documentroot">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Directory that forms the main document tree visiblefrom the web</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DocumentRoot <var>directory-path</var></code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>DocumentRoot /usr/local/apache/htdocs</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr></table> <p>This directive sets the directory from which <code class="program"><a href="../programs/httpd.html">httpd</a></code> will serve files. Unless matched by a directive like <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>, the server appends the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -