⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htaccess.html.en

📁 Apache HTTP Server 是一个功能强大的灵活的与HTTP/1.1相兼容的web服务器.这里给出的是Apache HTTP服务器的源码。
💻 EN
📖 第 1 页 / 共 2 页
字号:
    <div class="example"><h3>Section from your <code>httpd.conf</code>    file</h3><p><code>      &lt;Directory /www/htdocs/example&gt;<br />      <span class="indent">        AddType text/example .exm<br />      </span>      &lt;/Directory&gt;    </code></p></div>    <p>However, putting this configuration in your server configuration    file will result in less of a performance hit, as the configuration is    loaded once when Apache starts, rather than every time a file is    requested.</p>    <p>The use of <code>.htaccess</code> files can be disabled completely    by setting the <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code>    directive to <code>none</code>:</p>    <div class="example"><p><code>      AllowOverride None    </code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="how" id="how">How directives are applied</a></h2>    <p>The configuration directives found in a <code>.htaccess</code> file    are applied to the directory in which the <code>.htaccess</code> file    is found, and to all subdirectories thereof. However, it is important    to also remember that there may have been <code>.htaccess</code> files    in directories higher up. Directives are applied in the order that they    are found. Therefore, a <code>.htaccess</code> file in a particular    directory may override directives found in <code>.htaccess</code> files    found higher up in the directory tree. And those, in turn, may have    overridden directives found yet higher up, or in the main server    configuration file itself.</p>    <p>Example:</p>    <p>In the directory <code>/www/htdocs/example1</code> we have a    <code>.htaccess</code> file containing the following:</p>    <div class="example"><p><code>       Options +ExecCGI    </code></p></div>    <p>(Note: you must have "<code>AllowOverride Options</code>" in effect    to permit the use of the "<code class="directive"><a href="../mod/core.html#options">Options</a></code>" directive in    <code>.htaccess</code> files.)</p>    <p>In the directory <code>/www/htdocs/example1/example2</code> we have    a <code>.htaccess</code> file containing:</p>    <div class="example"><p><code>       Options Includes    </code></p></div>    <p>Because of this second <code>.htaccess</code> file, in the directory    <code>/www/htdocs/example1/example2</code>, CGI execution is not    permitted, as only <code>Options Includes</code> is in effect, which    completely overrides any earlier setting that may have been in    place.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="auth" id="auth">Authentication example</a></h2>    <p>If you jumped directly to this part of the document to find out how    to do authentication, it is important to note one thing. There is a    common misconception that you are required to use    <code>.htaccess</code> files in order to implement password    authentication. This is not the case. Putting authentication directives    in a <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>    section, in your main server configuration file, is the preferred way    to implement this, and <code>.htaccess</code> files should be used only    if you don't have access to the main server configuration file. See <a href="#when">above</a> for a discussion of when you should and should    not use <code>.htaccess</code> files.</p>    <p>Having said that, if you still think you need to use a    <code>.htaccess</code> file, you may find that a configuration such as    what follows may work for you.</p>    <p>You must have "<code>AllowOverride AuthConfig</code>" in effect for    these directives to be honored.</p>    <p><code>.htaccess</code> file contents:</p>    <div class="example"><p><code>      AuthType Basic<br />      AuthName "Password Required"<br />      AuthUserFile /www/passwords/password.file<br />      AuthGroupFile /www/passwords/group.file<br />      Require Group admins    </code></p></div>    <p>Note that <code>AllowOverride AuthConfig</code> must be in effect    for these directives to have any effect.</p>    <p>Please see the <a href="auth.html">authentication tutorial</a> for a    more complete discussion of authentication and authorization.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="ssi" id="ssi">Server Side Includes example</a></h2>    <p>Another common use of <code>.htaccess</code> files is to enable    Server Side Includes for a particular directory. This may be done with    the following configuration directives, placed in a    <code>.htaccess</code> file in the desired directory:</p>    <div class="example"><p><code>       Options +Includes<br />       AddType text/html shtml<br />       AddHandler server-parsed shtml    </code></p></div>    <p>Note that <code>AllowOverride Options</code> and <code>AllowOverride    FileInfo</code> must both be in effect for these directives to have any    effect.</p>    <p>Please see the <a href="ssi.html">SSI tutorial</a> for a more    complete discussion of server-side includes.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="cgi" id="cgi">CGI example</a></h2>    <p>Finally, you may wish to use a <code>.htaccess</code> file to permit    the execution of CGI programs in a particular directory. This may be    implemented with the following configuration:</p>    <div class="example"><p><code>       Options +ExecCGI<br />       AddHandler cgi-script cgi pl    </code></p></div>    <p>Alternately, if you wish to have all files in the given directory be    considered to be CGI programs, this may be done with the following    configuration:</p>    <div class="example"><p><code>       Options +ExecCGI<br />       SetHandler cgi-script    </code></p></div>    <p>Note that <code>AllowOverride Options</code> and <code>AllowOverride    FileInfo</code> must both be in effect for these directives to have any    effect.</p>    <p>Please see the <a href="cgi.html">CGI tutorial</a> for a more    complete discussion of CGI programming and configuration.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="troubleshoot" id="troubleshoot">Troubleshooting</a></h2>    <p>When you put configuration directives in a <code>.htaccess</code>    file, and you don't get the desired effect, there are a number of    things that may be going wrong.</p>    <p>Most commonly, the problem is that <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> is not    set such that your configuration directives are being honored. Make    sure that you don't have a <code>AllowOverride None</code> in effect    for the file scope in question. A good test for this is to put garbage    in your <code>.htaccess</code> file and reload. If a server error is    not generated, then you almost certainly have <code>AllowOverride    None</code> in effect.</p>    <p>If, on the other hand, you are getting server errors when trying to    access documents, check your Apache error log. It will likely tell you    that the directive used in your <code>.htaccess</code> file is not    permitted. Alternately, it may tell you that you had a syntax error,    which you will then need to fix.</p></div></div><div class="bottomlang"><p><span>Available Languages: </span><a href="../en/howto/htaccess.html" title="English">&nbsp;en&nbsp;</a> |<a href="../ja/howto/htaccess.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |<a href="../ko/howto/htaccess.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p></div><div id="footer"><p class="apache">Copyright 1995-2005 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p><p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -