diff options
Diffstat (limited to 'docs/manual/howto/htaccess.html.en')
-rw-r--r-- | docs/manual/howto/htaccess.html.en | 157 |
1 files changed, 88 insertions, 69 deletions
diff --git a/docs/manual/howto/htaccess.html.en b/docs/manual/howto/htaccess.html.en index af28a9fe..f3615896 100644 --- a/docs/manual/howto/htaccess.html.en +++ b/docs/manual/howto/htaccess.html.en @@ -5,18 +5,21 @@ This file is generated from xml source: DO NOT EDIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --> -<title>Apache Tutorial: .htaccess files - Apache HTTP Server</title> +<title>Apache HTTP Server Tutorial: .htaccess files - Apache HTTP Server</title> <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> -<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /> +<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<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> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> <div id="path"> -<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">How-To / Tutorials</a></div><div id="page-content"><div id="preamble"><h1>Apache Tutorial: .htaccess files</h1> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">How-To / Tutorials</a></div><div id="page-content"><div id="preamble"><h1>Apache HTTP Server Tutorial: .htaccess files</h1> <div class="toplang"> <p><span>Available Languages: </span><a href="../en/howto/htaccess.html" title="English"> en </a> | <a href="../fr/howto/htaccess.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | @@ -36,14 +39,14 @@ changes on a per-directory basis.</p> <li><img alt="" src="../images/down.gif" /> <a href="#ssi">Server Side Includes example</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#cgi">CGI example</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#troubleshoot">Troubleshooting</a></li> -</ul></div> +</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="related" id="related">.htaccess files</a></h2> - <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="../mod/core.html">core</a></code></li><li><code class="module"><a href="../mod/mod_authn_file.html">mod_authn_file</a></code></li><li><code class="module"><a href="../mod/mod_authz_groupfile.html">mod_authz_groupfile</a></code></li><li><code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code></li><li><code class="module"><a href="../mod/mod_include.html">mod_include</a></code></li><li><code class="module"><a href="../mod/mod_mime.html">mod_mime</a></code></li></ul></td><td><ul><li><code class="directive"><a href="../mod/core.html#accessfilename">AccessFileName</a></code></li><li><code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code></li><li><code class="directive"><a href="../mod/core.html#options">Options</a></code></li><li><code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code></li><li><code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code></li><li><code class="directive"><a href="../mod/mod_authn_core.html#authtype">AuthType</a></code></li><li><code class="directive"><a href="../mod/mod_authn_core.html#authname">AuthName</a></code></li><li><code class="directive"><a href="../mod/mod_authn_file.html#authuserfile">AuthUserFile</a></code></li><li><code class="directive"><a href="../mod/mod_authz_groupfile.html#authgroupfile">AuthGroupFile</a></code></li><li><code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code></li></ul></td></tr></table> + <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="../mod/core.html">core</a></code></li><li><code class="module"><a href="../mod/mod_authn_file.html">mod_authn_file</a></code></li><li><code class="module"><a href="../mod/mod_authz_groupfile.html">mod_authz_groupfile</a></code></li><li><code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code></li><li><code class="module"><a href="../mod/mod_include.html">mod_include</a></code></li><li><code class="module"><a href="../mod/mod_mime.html">mod_mime</a></code></li></ul></td><td><ul><li><code class="directive"><a href="../mod/core.html#accessfilename">AccessFileName</a></code></li><li><code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code></li><li><code class="directive"><a href="../mod/core.html#options">Options</a></code></li><li><code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code></li><li><code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code></li><li><code class="directive"><a href="../mod/core.html#authtype">AuthType</a></code></li><li><code class="directive"><a href="../mod/core.html#authname">AuthName</a></code></li><li><code class="directive"><a href="../mod/mod_authn_file.html#authuserfile">AuthUserFile</a></code></li><li><code class="directive"><a href="../mod/mod_authz_groupfile.html#authgroupfile">AuthGroupFile</a></code></li><li><code class="directive"><a href="../mod/core.html#require">Require</a></code></li></ul></td></tr></table> <div class="note">You should avoid using <code>.htaccess</code> files completely if you have access to - httpd main server config file. Using <code>.htaccess</code> files slows down your Apache server. + httpd main server config file. Using <code>.htaccess</code> files slows down your Apache http server. Any directive that you can include in a <code>.htaccess</code> file is better set in a <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> block, as it will have the same effect with better performance.</div> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -62,9 +65,8 @@ changes on a per-directory basis.</p> if you would rather call the file <code>.config</code> then you can put the following in your server configuration file:</p> - <div class="example"><p><code> - AccessFileName .config - </code></p></div> + <pre class="prettyprint lang-config">AccessFileName .config</pre> + </div> <p>In general, <code>.htaccess</code> files use the same syntax as @@ -108,7 +110,7 @@ changes on a per-directory basis.</p> you don't have access to the main server configuration file. There is, for example, a common misconception that user authentication should always be done in <code>.htaccess</code> files, and, in more recent years, - another miscomception that <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> directives + another misconception that <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> directives must go in <code>.htaccess</code> files. This is simply not the case. You can put user authentication configurations in the main server configuration, and this is, in fact, the preferred way to do @@ -135,18 +137,18 @@ changes on a per-directory basis.</p> <code>.htaccess</code> files.</p> <p>The first of these is performance. When <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> - is set to allow the use of <code>.htaccess</code> files, Apache will + is set to allow the use of <code>.htaccess</code> files, httpd will look in every directory for <code>.htaccess</code> files. Thus, permitting <code>.htaccess</code> files causes a performance hit, whether or not you actually even use them! Also, the <code>.htaccess</code> file is loaded every time a document is requested.</p> - <p>Further note that Apache must look for <code>.htaccess</code> files + <p>Further note that httpd must look for <code>.htaccess</code> files in all higher-level directories, in order to have a full complement of directives that it must apply. (See section on <a href="#how">how directives are applied</a>.) Thus, if a file is requested out of a - directory <code>/www/htdocs/example</code>, Apache must look for the + directory <code>/www/htdocs/example</code>, httpd must look for the following files:</p> <div class="example"><p><code> @@ -191,31 +193,28 @@ changes on a per-directory basis.</p> <p><code>.htaccess</code> file in <code>/www/htdocs/example</code>:</p> <div class="example"><h3>Contents of .htaccess file in - <code>/www/htdocs/example</code></h3><p><code> - AddType text/example .exm - </code></p></div> + <code>/www/htdocs/example</code></h3><pre class="prettyprint lang-config">AddType text/example .exm</pre> +</div> <div class="example"><h3>Section from your <code>httpd.conf</code> - file</h3><p><code> - <Directory /www/htdocs/example><br /> - <span class="indent"> - AddType text/example .exm<br /> - </span> - </Directory> - </code></p></div> + file</h3><pre class="prettyprint lang-config"> +<Directory /www/htdocs/example> + AddType text/example .exm +</Directory> + </pre> +</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 + loaded once when httpd 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> + <pre class="prettyprint lang-config">AllowOverride None</pre> + </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> @@ -236,9 +235,8 @@ changes on a per-directory basis.</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> + <pre class="prettyprint lang-config">Options +ExecCGI</pre> + <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 @@ -247,9 +245,8 @@ changes on a per-directory basis.</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> + <pre class="prettyprint lang-config">Options Includes</pre> + <p>Because of this second <code>.htaccess</code> file, in the directory <code>/www/htdocs/example1/example2</code>, CGI execution is not @@ -269,19 +266,16 @@ changes on a per-directory basis.</p> prevent script execution while allowing anything else to be set in <code>.htaccess</code> you can use:</p> - <div class="example"><p><code> -<Directory /www/htdocs><br /> -<span class="indent"> -Allowoverride All<br /> -</span> -</Directory><br /> -<br /> -<Location /><br /> -<span class="indent"> -Options +IncludesNoExec -ExecCGI<br /> -</span> + <pre class="prettyprint lang-config"> +<Directory /www/htdocs> + AllowOverride All +</Directory> + +<Location /> + Options +IncludesNoExec -ExecCGI<br /> </Location> - </code></p></div> + </pre> + <div class="note">This example assumes that your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> is <code>/www/htdocs</code>.</div> @@ -307,13 +301,14 @@ Options +IncludesNoExec -ExecCGI<br /> <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> + <pre class="prettyprint lang-config"> +AuthType Basic +AuthName "Password Required" +AuthUserFile /www/passwords/password.file +AuthGroupFile /www/passwords/group.file +Require Group admins + </pre> + <p>Note that <code>AllowOverride AuthConfig</code> must be in effect for these directives to have any effect.</p> @@ -329,11 +324,12 @@ Options +IncludesNoExec -ExecCGI<br /> 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> + <pre class="prettyprint lang-config"> +Options +Includes +AddType text/html shtml +AddHandler server-parsed shtml + </pre> + <p>Note that <code>AllowOverride Options</code> and <code>AllowOverride FileInfo</code> must both be in effect for these directives to have any @@ -349,19 +345,21 @@ Options +IncludesNoExec -ExecCGI<br /> 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> + <pre class="prettyprint lang-config"> +Options +ExecCGI +AddHandler cgi-script cgi pl + </pre> + <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> + <pre class="prettyprint lang-config"> +Options +ExecCGI +SetHandler cgi-script + </pre> + <p>Note that <code>AllowOverride Options</code> and <code>AllowOverride FileInfo</code> must both be in effect for these directives to have any @@ -387,7 +385,7 @@ Options +IncludesNoExec -ExecCGI<br /> 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 + access documents, check your httpd error log. It will likely tell you that the directive used in your <code>.htaccess</code> file is not permitted.</p> @@ -419,7 +417,28 @@ Options +IncludesNoExec -ExecCGI<br /> <a href="../ja/howto/htaccess.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | <a href="../ko/howto/htaccess.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | <a href="../pt-br/howto/htaccess.html" hreflang="pt-br" rel="alternate" title="Português (Brasil)"> pt-br </a></p> -</div><div id="footer"> +</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/howto/htaccess.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<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> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> </body></html>
\ No newline at end of file |