]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
docs: howto/htaccess.xml editorial cleanup
authorRich Bowen <rbowen@apache.org>
Fri, 19 Jun 2026 14:22:34 +0000 (14:22 +0000)
committerRich Bowen <rbowen@apache.org>
Fri, 19 Jun 2026 14:22:34 +0000 (14:22 +0000)
- Update example log dates to 2026
- Change error log highlight blocks from language="config" to "sh"
- Remove filler phrases: "in order to", "a lot of", "it is important
  to remember that", "simply"
- Convert inline "Note that..." prose to <note> blocks

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1935518 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/howto/htaccess.xml

index 16c1d2a369569ade0e4fde1be4d89adf500119d1..721d0071a52833d5f3d5c4e371b021890af5944f 100644 (file)
@@ -76,9 +76,11 @@ configuration files directly.</p>
       if you would rather call the file <code>.config</code> then you
       can put the following in your server configuration file:</p>
 
-      <highlight language="config">
+<example>
+<highlight language="config">
 AccessFileName ".config"
-      </highlight>
+</highlight>
+</example>
     </note>
 
     <p>Directives in <code>.htaccess</code> files use the same syntax as
@@ -93,7 +95,7 @@ AccessFileName ".config"
     directives to permit (see <a href="#when">below</a>). If a directive
     is permitted, the documentation for that directive will contain an Override section,
     specifying what value must be in <directive
-    module="core">AllowOverride</directive> in order for that
+    module="core">AllowOverride</directive> for that
     directive to be permitted.</p>
 
     <note>The default value of <directive
@@ -107,7 +109,7 @@ AccessFileName ".config"
     files. (See the Context line in the directive summary.) The <a
     href="../mod/directive-dict.html#Context">Override</a> line reads
     <code>FileInfo</code>. Thus, you must have at least
-    <code>AllowOverride FileInfo</code> in order for this directive to be
+    <code>AllowOverride FileInfo</code> for this directive to be
     honored in <code>.htaccess</code> files.</p>
     </section>
 
@@ -145,35 +147,37 @@ AccessFileName ".config"
     <code>.htaccess</code> file is loaded every time a document is
     requested.</p>
 
-    <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
+    <p>Additionally, httpd must look for <code>.htaccess</code> files
+    in all higher-level directories to assemble the full set of applicable
+    directives. (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>, httpd must look for the
     following files:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 /.htaccess
 /www/.htaccess
 /www/htdocs/.htaccess
 /www/htdocs/example/.htaccess
-    </highlight>
+</highlight>
+</example>
 
     <p>And so, for each file access out of that directory, there are 4
     additional file-system accesses, even if none of those files are
-    present. (Note that this would only be the case if
+    present. (This would only be the case if
     <code>.htaccess</code> files were enabled for <code>/</code>, which
     is not usually the case.)</p>
 
     <p><strong>Security:</strong> You are permitting
     users to modify server configuration, which may result in changes over
     which you have no control. Carefully consider whether you want to give
-    your users this privilege. Note also that giving users less
+    your users this privilege. Giving users less
     privileges than they need will lead to additional technical support
     requests. Make sure you clearly tell your users what level of
     privileges you have given them. Specifying exactly what you have set
     <directive module="core">AllowOverride</directive> to, and pointing them
-    to the relevant documentation, will save yourself a lot of confusion
+    to the relevant documentation, prevents confusion
     later.</p>
 
     <p>If you need to grant <code>.htaccess</code> access but want to
@@ -183,56 +187,62 @@ AccessFileName ".config"
     finer-grained control than <directive
     module="core">AllowOverride</directive> alone:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 # Allow only specific directives, not entire categories
 AllowOverride None
 AllowOverrideList Redirect RedirectMatch RewriteEngine RewriteRule RewriteCond
-    </highlight>
+</highlight>
+</example>
 
     <p>With this configuration, any directive not explicitly listed will
     cause a server error if encountered in a <code>.htaccess</code> file.
     This is a useful middle ground between full override access and no
     override access.</p>
 
-    <p>Note that it is completely equivalent to put a <code>.htaccess</code>
-    file in a directory <code>/www/htdocs/example</code> containing a
-    directive, and to put that same directive in a Directory section
-    <code>&lt;Directory "/www/htdocs/example"&gt;</code> in your main server
+    <p>Placing a directive in a <code>.htaccess</code>
+    file in a directory <code>/www/htdocs/example</code> is completely equivalent to placing that same directive in a
+    <code>&lt;Directory "/www/htdocs/example"&gt;</code> section in your main server
     configuration:</p>
 
     <p><code>.htaccess</code> file in <code>/www/htdocs/example</code>:</p>
 
     <example><title>Contents of .htaccess file in
     <code>/www/htdocs/example</code></title>
-    <highlight language="config">
+<example>
+<highlight language="config">
 AddType text/example ".exm"
-    </highlight>
+</highlight>
+</example>
     </example>
 
     <example><title>Section from your <code>httpd.conf</code>
     file</title>
-    <highlight language="config">
+<example>
+<highlight language="config">
 &lt;Directory "/www/htdocs/example"&gt;
-    AddType text/example ".exm"
+AddType text/example ".exm"
 &lt;/Directory&gt;
-    </highlight>
+</highlight>
+</example>
     </example>
 
     <p>The use of <code>.htaccess</code> files can be disabled completely
     by setting the <directive module="core">AllowOverride</directive>
     directive to <code>none</code>:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 AllowOverride None
-    </highlight>
+</highlight>
+</example>
 </section>
 
 <section id="how"><title>How directives are applied</title>
 
     <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
+    is found, and to all subdirectories thereof. 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
@@ -245,21 +255,25 @@ AllowOverride None
     <p>In the directory <code>/www/htdocs/example1</code> we have a
     <code>.htaccess</code> file containing the following:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 Options +ExecCGI
-    </highlight>
+</highlight>
+</example>
 
-    <p>(Note: you must have "<code>AllowOverride Options</code>" in effect
+    <note>You must have "<code>AllowOverride Options</code>" in effect
     to permit the use of the "<directive
     module="core">Options</directive>" directive in
-    <code>.htaccess</code> files.)</p>
+    <code>.htaccess</code> files.</note>
 
     <p>In the directory <code>/www/htdocs/example1/example2</code> we have
     a <code>.htaccess</code> file containing:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 Options Includes
-    </highlight>
+</highlight>
+</example>
 
     <p>Because of this second <code>.htaccess</code> file, in the directory
     <code>/www/htdocs/example1/example2</code>, CGI execution is not
@@ -282,15 +296,17 @@ Options Includes
     prevent script execution while allowing anything else to be set in
     <code>.htaccess</code> you can use:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 &lt;Directory "/www/htdocs"&gt;
-    AllowOverride All
+AllowOverride All
 &lt;/Directory&gt;
 
 &lt;Location "/"&gt;
-    Options +IncludesNoExec -ExecCGI
+Options +IncludesNoExec -ExecCGI
 &lt;/Location&gt;
-    </highlight>
+</highlight>
+</example>
 
     <note>This example assumes that your <directive
     module="core">DocumentRoot</directive> is <code>/www/htdocs</code>.</note>
@@ -308,16 +324,18 @@ Options Includes
 
     <p><code>.htaccess</code> file contents:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 AuthType Basic
 AuthName "Password Required"
 AuthUserFile "/www/passwords/password.file"
 AuthGroupFile "/www/passwords/group.file"
 Require group admins
-    </highlight>
+</highlight>
+</example>
 
-    <p>Note that <code>AllowOverride AuthConfig</code> must be in effect
-    for these directives to have any effect.</p>
+    <note><code>AllowOverride AuthConfig</code> must be in effect
+    for these directives to have any effect.</note>
 
     <p>Please see the <a href="auth.html">authentication tutorial</a> for a
     more complete discussion of authentication and authorization.</p>
@@ -330,15 +348,17 @@ Require group admins
     configuration directives, placed in a <code>.htaccess</code> file in
     the desired directory:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 Options +Includes
 AddType text/html "shtml"
 AddHandler server-parsed shtml
-    </highlight>
+</highlight>
+</example>
 
-    <p>Note that <code>AllowOverride Options</code> and <code>AllowOverride
+    <note><code>AllowOverride Options</code> and <code>AllowOverride
     FileInfo</code> must both be in effect for these directives to have any
-    effect.</p>
+    effect.</note>
 
     <p>Please see the <a href="ssi.html">SSI tutorial</a> for a more
     complete discussion of server-side includes.</p>
@@ -351,6 +371,7 @@ changes things a bit. In particular, rules are taken to be relative to
 the current directory, rather than being the original requested URI.
 Consider the following examples:</p>
 
+<example>
 <highlight language="config">
 # In httpd.conf
 RewriteRule "^/images/(.+)\.jpg" "/images/$1.png"
@@ -361,6 +382,7 @@ RewriteRule "^images/(.+)\.jpg" "images/$1.png"
 # In .htaccess in images/
 RewriteRule "^(.+)\.jpg" "$1.png"
 </highlight>
+</example>
 
 <p>In a <code>.htaccess</code> in your document directory, the leading
 slash is removed from the value supplied to <directive
@@ -369,7 +391,7 @@ module="mod_rewrite">RewriteRule</directive>, and in the
 it. Thus, your regular expression needs to omit that portion as
 well.</p>
 
-<p>Also note that in <code>.htaccess</code> context, regular expressions are
+<p>In <code>.htaccess</code> context, regular expressions are
 recompiled on every request, whereas in the main server configuration they
 are compiled once and cached.</p>
 
@@ -390,23 +412,27 @@ further details on using <module>mod_rewrite</module>.</p>
     execution of CGI programs in a particular directory. This may be
     implemented with the following configuration:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 Options +ExecCGI
 AddHandler cgi-script "cgi" "py"
-    </highlight>
+</highlight>
+</example>
 
     <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>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 Options +ExecCGI
 SetHandler cgi-script
-    </highlight>
+</highlight>
+</example>
 
-    <p>Note that <code>AllowOverride Options</code> and <code>AllowOverride
+    <note><code>AllowOverride Options</code> and <code>AllowOverride
     FileInfo</code> must both be in effect for these directives to have any
-    effect.</p>
+    effect.</note>
 
     <p>Please see the <a href="cgi.html">CGI tutorial</a> for a more
     complete discussion of CGI programming and configuration.</p>
@@ -427,9 +453,11 @@ SetHandler cgi-script
     nonsense word in your <code>.htaccess</code> file and reload the
     page:</p>
 
-    <highlight language="config">
+<example>
+<highlight language="config">
 TestMe
-    </highlight>
+</highlight>
+</example>
 
     <p>If a server error (HTTP 500) is
     not generated, then you almost certainly have <code>AllowOverride
@@ -440,13 +468,14 @@ TestMe
     that the directive used in your <code>.htaccess</code> file is not
     permitted.</p>
 
-    <highlight language="config">
-[Tue May 06 09:12:31.528374 2025] [core:alert] [pid 12345] [client 192.168.1.50:54321] /var/www/html/.htaccess: DirectoryIndex not allowed here
-    </highlight>
+<example>
+<highlight language="sh">
+[Thu Jun 18 09:12:31.528374 2026] [core:alert] [pid 12345] [client 192.168.1.50:54321] /var/www/html/.htaccess: DirectoryIndex not allowed here
+</highlight>
+</example>
 
     <p>This will indicate either that you've used a directive that is
-    never permitted in <code>.htaccess</code> files, or that you simply
-    don't have <directive module="core">AllowOverride</directive> set to
+    never permitted in <code>.htaccess</code> files, or that you don't have <directive module="core">AllowOverride</directive> set to
     a level sufficient for the directive you've used. Consult the
     documentation for that particular directive to determine which is
     the case.</p>
@@ -454,9 +483,11 @@ TestMe
     <p>Alternately, it may tell you that you had a syntax error in your
     usage of the directive itself.</p>
 
-    <highlight language="config">
-[Tue May 06 09:14:02.946218 2025] [core:alert] [pid 12345] [client 192.168.1.50:54321] /var/www/html/.htaccess: RewriteCond: bad flag delimiters
-    </highlight>
+<example>
+<highlight language="sh">
+[Thu Jun 18 09:14:02.946218 2026] [core:alert] [pid 12345] [client 192.168.1.50:54321] /var/www/html/.htaccess: RewriteCond: bad flag delimiters
+</highlight>
+</example>
 
     <p>In this case, the error message should be specific to the
     particular syntax error that you have committed.</p>