You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2009/11/03 01:16:58 UTC

svn commit: r832217 - in /httpd/httpd/trunk/docs/manual/rewrite: index.html.en index.xml index.xml.tr remapping.html.en remapping.xml rewrite_guide.html.en rewrite_guide.xml

Author: rbowen
Date: Tue Nov  3 00:16:57 2009
New Revision: 832217

URL: http://svn.apache.org/viewvc?rev=832217&view=rev
Log:
Moves another rule out of rewrite_guide, and updates it for modern
versions of mod_rewrite

Modified:
    httpd/httpd/trunk/docs/manual/rewrite/index.html.en
    httpd/httpd/trunk/docs/manual/rewrite/index.xml
    httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr
    httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en
    httpd/httpd/trunk/docs/manual/rewrite/remapping.xml
    httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en
    httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml

Modified: httpd/httpd/trunk/docs/manual/rewrite/index.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/index.html.en?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/index.html.en (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/index.html.en Tue Nov  3 00:16:57 2009
@@ -58,6 +58,8 @@
 <li><a href="intro.html">Introduction to regular expressions and
 mod_rewrite</a></li>
 <li><a href="rewrite_guide.html">Rewrite Guide - useful examples</a></li>
+<li><a href="remapping.html">Using mod_rewrite for redirection and
+remapping of URLs</a></li>
 <li><a href="access.html">Using mod_rewrite to control access</a></li>
 <li><a href="flags.html">Flags</a></li>
 <li><a href="tech.html">Technical details</a></li>

Modified: httpd/httpd/trunk/docs/manual/rewrite/index.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/index.xml?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/index.xml (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/index.xml Tue Nov  3 00:16:57 2009
@@ -64,6 +64,8 @@
 <li><a href="intro.html">Introduction to regular expressions and
 mod_rewrite</a></li>
 <li><a href="rewrite_guide.html">Rewrite Guide - useful examples</a></li>
+<li><a href="remapping.html">Using mod_rewrite for redirection and
+remapping of URLs</a></li>
 <li><a href="access.html">Using mod_rewrite to control access</a></li>
 <li><a href="flags.html">Flags</a></li>
 <li><a href="tech.html">Technical details</a></li>

Modified: httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr [utf-8] (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr [utf-8] Tue Nov  3 00:16:57 2009
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='UTF-8' ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 636374:832069 (outdated) -->
+<!-- English Revision: 636374:832183 (outdated) -->
 <!-- =====================================================
  Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
    Reviewed by: Orhan Berent <berent belgeler.org>

Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en Tue Nov  3 00:16:57 2009
@@ -37,7 +37,9 @@
 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#old-to-new">From Old to New (internal)</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#old-to-new-extern">Rewriting From Old to New (external)</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#static-to-dynamic">From Static to Dynamic</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#backward-compatibility">Backward Compatibility for file extension change</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#canonicalhost">Canonical Hostnames</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#multipledirs">Search for pages in more than one directory</a></li>
 </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li></ul></div>
 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
@@ -150,6 +152,54 @@
 
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
+<h2><a name="backward-compatibility" id="backward-compatibility">Backward Compatibility for file extension change</a></h2>
+
+  
+
+  <dl>
+    <dt>Description:</dt>
+
+    <dd>
+      <p>How can we make URLs backward compatible (still
+      existing virtually) after migrating <code>document.YYYY</code>
+      to <code>document.XXXX</code>, e.g. after translating a
+      bunch of <code>.html</code> files to <code>.php</code>?</p>
+    </dd>
+
+    <dt>Solution:</dt>
+
+    <dd>
+      <p>We rewrite the name to its basename and test for
+      existence of the new extension. If it exists, we take
+      that name, else we rewrite the URL to its original state.</p>
+
+<div class="example"><pre>
+#   backward compatibility ruleset for
+#   rewriting document.html to document.php
+#   when and only when document.php exists
+RewriteEngine on
+
+RewriteCond $1.php -f
+RewriteCond $1.html !-f
+RewriteRule ^(.*).html$ $1.php 
+</pre></div>
+    </dd>
+
+    <dt>Discussion</dt>
+    <dd>
+    <p>This example uses an often-overlooked feature of mod_rewrite,
+    by taking advantage of the order of execution of the ruleset. In
+    particular, mod_rewrite evaluates the left-hand-side of the
+    RewriteRule before it evaluates the RewriteCond directives.
+    Consequently, $1 is already defined by the time the RewriteRule
+    directives are evaluated. This allows us to test for the existence
+    of the the original (<code>document.html</code>) and target
+    (<code>document.php</code>) files using the same base filename.</p>
+    </dd>
+  </dl>
+
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
 <h2><a name="canonicalhost" id="canonicalhost">Canonical Hostnames</a></h2>
 
       <dl>
@@ -198,7 +248,50 @@
         </dd>
       </dl>
 
-    </div></div>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="multipledirs" id="multipledirs">Search for pages in more than one directory</a></h2>
+
+  
+
+  <dl>
+    <dt>Description:</dt>
+
+    <dd>
+      <p>A particular resource might exist in one of several places, and
+      we want to look in those places for the resource when it is
+      requested. Perhaps we've recently rearranged our directory
+      structure, dividing content into several locations.</p>
+    </dd>
+
+    <dt>Solution:</dt>
+
+    <dd>
+      <p>The following ruleset searches in two directories to find the
+      resource, and, if not finding it in either place, will attempt to
+      just serve it out of the location requested.</p>
+
+<div class="example"><pre>
+RewriteEngine on
+
+#   first try to find it in dir1/...
+#   ...and if found stop and be happy:
+RewriteCond         %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}  -f
+RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1  [L]
+
+#   second try to find it in dir2/...
+#   ...and if found stop and be happy:
+RewriteCond         %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}  -f
+RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1  [L]
+
+#   else go on for other Alias or ScriptAlias directives,
+#   etc.
+RewriteRule   ^(.+)  -  [PT]
+</pre></div>
+    </dd>
+  </dl>
+
+</div></div>
 <div class="bottomlang">
 <p><span>Available Languages: </span><a href="../en/rewrite/remapping.html" title="English">&nbsp;en&nbsp;</a></p>
 </div><div id="footer">

Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.xml?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/remapping.xml (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/remapping.xml Tue Nov  3 00:16:57 2009
@@ -152,6 +152,54 @@
 
 </section>
 
+<section id="backward-compatibility">
+
+  <title>Backward Compatibility for file extension change</title>
+
+  <dl>
+    <dt>Description:</dt>
+
+    <dd>
+      <p>How can we make URLs backward compatible (still
+      existing virtually) after migrating <code>document.YYYY</code>
+      to <code>document.XXXX</code>, e.g. after translating a
+      bunch of <code>.html</code> files to <code>.php</code>?</p>
+    </dd>
+
+    <dt>Solution:</dt>
+
+    <dd>
+      <p>We rewrite the name to its basename and test for
+      existence of the new extension. If it exists, we take
+      that name, else we rewrite the URL to its original state.</p>
+
+<example><pre>
+#   backward compatibility ruleset for
+#   rewriting document.html to document.php
+#   when and only when document.php exists
+RewriteEngine on
+
+RewriteCond $1.php -f
+RewriteCond $1.html !-f
+RewriteRule ^(.*).html$ $1.php 
+</pre></example>
+    </dd>
+
+    <dt>Discussion</dt>
+    <dd>
+    <p>This example uses an often-overlooked feature of mod_rewrite,
+    by taking advantage of the order of execution of the ruleset. In
+    particular, mod_rewrite evaluates the left-hand-side of the
+    RewriteRule before it evaluates the RewriteCond directives.
+    Consequently, $1 is already defined by the time the RewriteRule
+    directives are evaluated. This allows us to test for the existence
+    of the the original (<code>document.html</code>) and target
+    (<code>document.php</code>) files using the same base filename.</p>
+    </dd>
+  </dl>
+
+</section>
+
 <section id="canonicalhost"><title>Canonical Hostnames</title>
 
       <dl>
@@ -201,6 +249,49 @@
         </dd>
       </dl>
 
-    </section>
+</section>
+
+<section id="multipledirs">
+
+  <title>Search for pages in more than one directory</title>
+
+  <dl>
+    <dt>Description:</dt>
+
+    <dd>
+      <p>A particular resource might exist in one of several places, and
+      we want to look in those places for the resource when it is
+      requested. Perhaps we've recently rearranged our directory
+      structure, dividing content into several locations.</p>
+    </dd>
+
+    <dt>Solution:</dt>
+
+    <dd>
+      <p>The following ruleset searches in two directories to find the
+      resource, and, if not finding it in either place, will attempt to
+      just serve it out of the location requested.</p>
+
+<example><pre>
+RewriteEngine on
+
+#   first try to find it in dir1/...
+#   ...and if found stop and be happy:
+RewriteCond         %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}  -f
+RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1  [L]
+
+#   second try to find it in dir2/...
+#   ...and if found stop and be happy:
+RewriteCond         %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}  -f
+RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1  [L]
+
+#   else go on for other Alias or ScriptAlias directives,
+#   etc.
+RewriteRule   ^(.+)  -  [PT]
+</pre></example>
+    </dd>
+  </dl>
+
+</section>
 
 </manualpage> 

Modified: httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en Tue Nov  3 00:16:57 2009
@@ -45,13 +45,11 @@
 <li><img alt="" src="../images/down.gif" /> <a href="#moveddocroot">Moved <code>DocumentRoot</code></a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#trailingslash">Trailing Slash Problem</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#movehomedirs">Move Homedirs to Different Webserver</a></li>
-<li><img alt="" src="../images/down.gif" /> <a href="#multipledirs">Search for pages in more than one directory</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#setenvvars">Set Environment Variables According To URL Parts</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual Hosts Per User</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#redirecthome">Redirect Homedirs For Foreigners</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#redirectanchors">Redirecting Anchors</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#time-dependent">Time-Dependent Rewriting</a></li>
-<li><img alt="" src="../images/down.gif" /> <a href="#backward-compatibility">Backward Compatibility for YYYY to XXXX migration</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#proxy-deny">Proxy Deny</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#external-rewriting">External Rewriting Engine</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#cluster">Web Cluster with Consistent URL Space</a></li>
@@ -245,47 +243,6 @@
 
     </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
-<h2><a name="multipledirs" id="multipledirs">Search for pages in more than one directory</a></h2>
-
-      
-
-      <dl>
-        <dt>Description:</dt>
-
-        <dd>
-          <p>Sometimes it is necessary to let the webserver search
-          for pages in more than one directory. Here MultiViews or
-          other techniques cannot help.</p>
-        </dd>
-
-        <dt>Solution:</dt>
-
-        <dd>
-          <p>We program a explicit ruleset which searches for the
-          files in the directories.</p>
-
-<div class="example"><pre>
-RewriteEngine on
-
-#   first try to find it in dir1/...
-#   ...and if found stop and be happy:
-RewriteCond         %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}  -f
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1  [L]
-
-#   second try to find it in dir2/...
-#   ...and if found stop and be happy:
-RewriteCond         %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}  -f
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1  [L]
-
-#   else go on for other Alias or ScriptAlias directives,
-#   etc.
-RewriteRule   ^(.+)  -  [PT]
-</pre></div>
-        </dd>
-      </dl>
-
-    </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
-<div class="section">
 <h2><a name="setenvvars" id="setenvvars">Set Environment Variables According To URL Parts</a></h2>
 
       
@@ -455,51 +412,6 @@
 
     </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
-<h2><a name="backward-compatibility" id="backward-compatibility">Backward Compatibility for YYYY to XXXX migration</a></h2>
-
-      
-
-      <dl>
-        <dt>Description:</dt>
-
-        <dd>
-          <p>How can we make URLs backward compatible (still
-          existing virtually) after migrating <code>document.YYYY</code>
-          to <code>document.XXXX</code>, e.g. after translating a
-          bunch of <code>.html</code> files to <code>.phtml</code>?</p>
-        </dd>
-
-        <dt>Solution:</dt>
-
-        <dd>
-          <p>We just rewrite the name to its basename and test for
-          existence of the new extension. If it exists, we take
-          that name, else we rewrite the URL to its original state.</p>
-
-
-<div class="example"><pre>
-#   backward compatibility ruleset for
-#   rewriting document.html to document.phtml
-#   when and only when document.phtml exists
-#   but no longer document.html
-RewriteEngine on
-RewriteBase   /~quux/
-#   parse out basename, but remember the fact
-RewriteRule   ^(.*)\.html$              $1      [C,E=WasHTML:yes]
-#   rewrite to document.phtml if exists
-#   Note: This is a per-directory example, so %{REQUEST_FILENAME} is the full 
-#         filesystem path as already mapped by the server.
-RewriteCond   %{REQUEST_FILENAME}.phtml -f
-RewriteRule   ^(.*)$ $1.phtml                   [S=1]
-#   else reverse the previous basename cutout
-RewriteCond   %{ENV:WasHTML}            ^yes$
-RewriteRule   ^(.*)$ $1.html
-</pre></div>
-        </dd>
-      </dl>
-
-    </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
-<div class="section">
 <h2><a name="proxy-deny" id="proxy-deny">Proxy Deny</a></h2>
 
       

Modified: httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml?rev=832217&r1=832216&r2=832217&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml Tue Nov  3 00:16:57 2009
@@ -223,47 +223,6 @@
 
     </section>
 
-    <section id="multipledirs">
-
-      <title>Search for pages in more than one directory</title>
-
-      <dl>
-        <dt>Description:</dt>
-
-        <dd>
-          <p>Sometimes it is necessary to let the webserver search
-          for pages in more than one directory. Here MultiViews or
-          other techniques cannot help.</p>
-        </dd>
-
-        <dt>Solution:</dt>
-
-        <dd>
-          <p>We program a explicit ruleset which searches for the
-          files in the directories.</p>
-
-<example><pre>
-RewriteEngine on
-
-#   first try to find it in dir1/...
-#   ...and if found stop and be happy:
-RewriteCond         %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}  -f
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1  [L]
-
-#   second try to find it in dir2/...
-#   ...and if found stop and be happy:
-RewriteCond         %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}  -f
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1  [L]
-
-#   else go on for other Alias or ScriptAlias directives,
-#   etc.
-RewriteRule   ^(.+)  -  [PT]
-</pre></example>
-        </dd>
-      </dl>
-
-    </section>
-
     <section id="setenvvars">
 
       <title>Set Environment Variables According To URL Parts</title>
@@ -434,51 +393,6 @@
 
     </section>
 
-    <section id="backward-compatibility">
-
-      <title>Backward Compatibility for YYYY to XXXX migration</title>
-
-      <dl>
-        <dt>Description:</dt>
-
-        <dd>
-          <p>How can we make URLs backward compatible (still
-          existing virtually) after migrating <code>document.YYYY</code>
-          to <code>document.XXXX</code>, e.g. after translating a
-          bunch of <code>.html</code> files to <code>.phtml</code>?</p>
-        </dd>
-
-        <dt>Solution:</dt>
-
-        <dd>
-          <p>We just rewrite the name to its basename and test for
-          existence of the new extension. If it exists, we take
-          that name, else we rewrite the URL to its original state.</p>
-
-
-<example><pre>
-#   backward compatibility ruleset for
-#   rewriting document.html to document.phtml
-#   when and only when document.phtml exists
-#   but no longer document.html
-RewriteEngine on
-RewriteBase   /~quux/
-#   parse out basename, but remember the fact
-RewriteRule   ^(.*)\.html$              $1      [C,E=WasHTML:yes]
-#   rewrite to document.phtml if exists
-#   Note: This is a per-directory example, so %{REQUEST_FILENAME} is the full 
-#         filesystem path as already mapped by the server.
-RewriteCond   %{REQUEST_FILENAME}.phtml -f
-RewriteRule   ^(.*)$ $1.phtml                   [S=1]
-#   else reverse the previous basename cutout
-RewriteCond   %{ENV:WasHTML}            ^yes$
-RewriteRule   ^(.*)$ $1.html
-</pre></example>
-        </dd>
-      </dl>
-
-    </section>
-
     <section id="proxy-deny">
 
       <title>Proxy Deny</title>



Re: svn commit: r832217 - in /httpd/httpd/trunk/docs/manual/rewrite: index.html.en index.xml index.xml.tr remapping.html.en remapping.xml rewrite_guide.html.en rewrite_guide.xml

Posted by Rich Bowen <rb...@rcbowen.com>.
On Nov 3, 2009, at 06:36 , Bob Ionescu wrote:

>>
>> +#   backward compatibility ruleset for
>> +#   rewriting document.html to document.php
>> +#   when and only when document.php exists
>> +RewriteEngine on
>> +
>> +RewriteCond $1.php -f
>> +RewriteCond $1.html !-f
>> +RewriteRule ^(.*).html$ $1.php
>
> I think this will lead to problems since $1 should contain (in per-dir
> context) only local/foo and not /full/physical/path/to/local/foo as
> required by apr_stat().


Ah. We need a RewriteBase on there. Thanks.

--
Rich Bowen
rbowen@rcbowen.com




---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Re: svn commit: r832217 - in /httpd/httpd/trunk/docs/manual/rewrite: index.html.en index.xml index.xml.tr remapping.html.en remapping.xml rewrite_guide.html.en rewrite_guide.xml

Posted by Eric Covener <co...@gmail.com>.
On Wed, Nov 4, 2009 at 1:19 PM, Rich Bowen <rb...@rcbowen.com> wrote:
> Will this fix it? :
>
>
> @@ -177,11 +177,14 @@
>  #   backward compatibility ruleset for
>  #   rewriting document.html to document.php
>  #   when and only when document.php exists
> +&lt;Directory /var/www/htdocs&gt;
>  RewriteEngine on
> +RewriteBase /var/www/htdocs
>
>  RewriteCond $1.php -f
>  RewriteCond $1.html !-f
> -RewriteRule ^(.*).html$ $1.php
> +RewriteRule ^(.*).html$ $1.php
> +&lt;/Directory&gt;
>  </pre></example>
>     </dd>

RewriteBase is the URL-path, not the filesystem path.  And I don't
think test strings in a condition are expanded with respect to the
base.

You can figure out where the first pass landed by using
%{REQUEST_FILENAME} in per-dir context:

Alias /a /tmp/a
<directory /tmp/a>
RewriteBase /a
RewriteEngine on
# full path in per-directory contet
RewriteCond %{REQUEST_FILENAME} (.*)\.html$
RewriteCond %1.php -f
RewriteRule (.*)\.html$ $1.php
</directory>


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Re: svn commit: r832217 - in /httpd/httpd/trunk/docs/manual/rewrite: index.html.en index.xml index.xml.tr remapping.html.en remapping.xml rewrite_guide.html.en rewrite_guide.xml

Posted by Rich Bowen <rb...@rcbowen.com>.
Will this fix it? :


@@ -177,11 +177,14 @@
  #   backward compatibility ruleset for
  #   rewriting document.html to document.php
  #   when and only when document.php exists
+&lt;Directory /var/www/htdocs&gt;
  RewriteEngine on
+RewriteBase /var/www/htdocs

  RewriteCond $1.php -f
  RewriteCond $1.html !-f
-RewriteRule ^(.*).html$ $1.php
+RewriteRule ^(.*).html$ $1.php
+&lt;/Directory&gt;
  </pre></example>
      </dd>



On Nov 3, 2009, at 06:36 , Bob Ionescu wrote:

> 2009/11/3  <rb...@apache.org>:
>> Author: rbowen
>> Date: Tue Nov  3 00:16:57 2009
>> New Revision: 832217
>>
>> URL: http://svn.apache.org/viewvc?rev=832217&view=rev
>> Log:
>> Moves another rule out of rewrite_guide, and updates it for modern
>> versions of mod_rewrite
>>
>> Modified:
>>   httpd/httpd/trunk/docs/manual/rewrite/index.html.en
>>   httpd/httpd/trunk/docs/manual/rewrite/index.xml
>>   httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr
>>   httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en
>>   httpd/httpd/trunk/docs/manual/rewrite/remapping.xml
>>   httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en
>>   httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml
> [...
> ]> +<div class="example"><pre>
>> +#   backward compatibility ruleset for
>> +#   rewriting document.html to document.php
>> +#   when and only when document.php exists
>> +RewriteEngine on
>> +
>> +RewriteCond $1.php -f
>> +RewriteCond $1.html !-f
>> +RewriteRule ^(.*).html$ $1.php
>
> I think this will lead to problems since $1 should contain (in per-dir
> context) only local/foo and not /full/physical/path/to/local/foo as
> required by apr_stat().
>
> Bob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
> For additional commands, e-mail: docs-help@httpd.apache.org
>

--
Rich Bowen
rbowen@rcbowen.com




---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Re: svn commit: r832217 - in /httpd/httpd/trunk/docs/manual/rewrite: index.html.en index.xml index.xml.tr remapping.html.en remapping.xml rewrite_guide.html.en rewrite_guide.xml

Posted by Bob Ionescu <bo...@googlemail.com>.
2009/11/3  <rb...@apache.org>:
> Author: rbowen
> Date: Tue Nov  3 00:16:57 2009
> New Revision: 832217
>
> URL: http://svn.apache.org/viewvc?rev=832217&view=rev
> Log:
> Moves another rule out of rewrite_guide, and updates it for modern
> versions of mod_rewrite
>
> Modified:
>    httpd/httpd/trunk/docs/manual/rewrite/index.html.en
>    httpd/httpd/trunk/docs/manual/rewrite/index.xml
>    httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr
>    httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en
>    httpd/httpd/trunk/docs/manual/rewrite/remapping.xml
>    httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en
>    httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml
[...
]> +<div class="example"><pre>
> +#   backward compatibility ruleset for
> +#   rewriting document.html to document.php
> +#   when and only when document.php exists
> +RewriteEngine on
> +
> +RewriteCond $1.php -f
> +RewriteCond $1.html !-f
> +RewriteRule ^(.*).html$ $1.php

I think this will lead to problems since $1 should contain (in per-dir
context) only local/foo and not /full/physical/path/to/local/foo as
required by apr_stat().

Bob

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org