httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbo...@apache.org
Subject svn commit: r1651479 - in /httpd/httpd/trunk/docs/manual/howto: htaccess.html.en htaccess.xml
Date Tue, 13 Jan 2015 20:39:34 GMT
Author: rbowen
Date: Tue Jan 13 20:39:34 2015
New Revision: 1651479

URL: http://svn.apache.org/r1651479
Log:
Insert .htaccess example talking about relative paths when using
mod_rewrite in .htaccess files.

Modified:
    httpd/httpd/trunk/docs/manual/howto/htaccess.html.en
    httpd/httpd/trunk/docs/manual/howto/htaccess.xml

Modified: httpd/httpd/trunk/docs/manual/howto/htaccess.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/howto/htaccess.html.en?rev=1651479&r1=1651478&r2=1651479&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/howto/htaccess.html.en (original)
+++ httpd/httpd/trunk/docs/manual/howto/htaccess.html.en Tue Jan 13 20:39:34 2015
@@ -37,6 +37,7 @@ changes on a per-directory basis.</p>
 <li><img alt="" src="../images/down.gif" /> <a href="#how">How directives
are applied</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#auth">Authentication
example</a></li>
 <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="#rewrite">Rewrite
Rules in .htaccess files</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><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
@@ -331,6 +332,34 @@ AddHandler server-parsed shtml</pre>
     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="rewrite" id="rewrite">Rewrite Rules in .htaccess files</a></h2>
+<p>When using <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>
in
+<code>.htaccess</code> files, be aware that the per-directory context
+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>
+
+<pre class="prettyprint lang-config"># In httpd.conf
+RewriteRule ^/images/(.+)\.jpg /images/$1.png
+
+# In .htaccess in root dir
+RewriteRule ^images/(.+)\.jpg images/$1.png
+
+# In .htaccess in images/
+RewriteRule ^(.+)\.jpg $1.png</pre>
+
+
+<p>In a <code>.htaccess</code> in your document directory, the leading
+slash is removed from the value supplied to <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>,
and in the
+<code>images</code> subdirectory, <code>/images/</code> is removed
from
+it. Thus, your regular expression needs to omit that portion as
+well.</p>
+
+<p>Consult the <a href="../rewrite/">mod_rewrite documentation</a> for
+further details on using <code>mod_rewrite</code>.</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

Modified: httpd/httpd/trunk/docs/manual/howto/htaccess.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/howto/htaccess.xml?rev=1651479&r1=1651478&r2=1651479&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/howto/htaccess.xml (original)
+++ httpd/httpd/trunk/docs/manual/howto/htaccess.xml Tue Jan 13 20:39:34 2015
@@ -363,6 +363,36 @@ AddHandler server-parsed shtml
     complete discussion of server-side includes.</p>
 </section>
 
+<section id="rewrite"><title>Rewrite Rules in .htaccess files</title>
+<p>When using <directive module="mod_rewrite">RewriteRule</directive> in
+<code>.htaccess</code> files, be aware that the per-directory context
+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>
+
+<highlight language="config">
+# In httpd.conf
+RewriteRule ^/images/(.+)\.jpg /images/$1.png
+
+# In .htaccess in root dir
+RewriteRule ^images/(.+)\.jpg images/$1.png
+
+# In .htaccess in images/
+RewriteRule ^(.+)\.jpg $1.png
+</highlight>
+
+<p>In a <code>.htaccess</code> in your document directory, the leading
+slash is removed from the value supplied to <directive
+module="mod_rewrite">RewriteRule</directive>, and in the
+<code>images</code> subdirectory, <code>/images/</code> is removed
from
+it. Thus, your regular expression needs to omit that portion as
+well.</p>
+
+<p>Consult the <a href="../rewrite/">mod_rewrite documentation</a> for
+further details on using <code>mod_rewrite</code>.</p>
+
+</section>
+
 <section id="cgi"><title>CGI example</title>
 
     <p>Finally, you may wish to use a <code>.htaccess</code> file to permit



Mime
View raw message