title: Apache mod_rewrite catch all (.*) does not work as intended
body: <p>Following is an excerpt of my <code>httpd.conf</code>. I want to catch all unmatched requests at <code>[2]</code> and reverse proxy to <code>http://localhost:8585</code>. However, all links were sent to <code>http://localhost:8585/var/ww/html/</code></p>
  
  <pre><code>DocumentRoot "/var/www/html"
  
  &lt;Directory /&gt;
      Options FollowSymLinks
      AllowOverride None
      RewriteEngine on
      RewriteRule testing/(.*) http://localhost:8585/mytesting/$1 [P,L] # [1]
      RewriteRule (.*) http://localhost:8585/$1 [P,L] # [2] Catch all Rule
  
  &lt;/Directory&gt;
  </code></pre>
  
  <p>Here are some test I tried and the result after rewrite</p>
  
  <p>Good Result</p>
  
  <p><code>http://localhost/testing/</code> => <code>http://localhost:8585/mytesting/</code> [3]
  <code>http://localhost/testing/goodOne</code> => <code>http://localhost:8585/mytesting/goodOne</code> [4]</p>
  
  <p>Bad Result</p>
  
  <p><code>http://localhost:8080/testing</code> => <code>http://localhost:8585/var/www/html/testing</code> [5]  I expect <code>http://localhost:8585/testing</code></p>
  
  <p><code>http://localhost:8080/</code> => <code>http://localhost:8585/var/www/html/</code> [6]   I expect <code>http://localhost:8585/</code></p>
  
  <p>The problem is obvious that the last <code>RewriteRule</code> prepended <code>DocumentRoot</code>(/var/www/html/) after the rewrite. Did I do something wrong? Or is this the intended behavior? And how can I fix/workaround this to have my expected result?</p>
  
  <p>Output from <code>RewriteLog</code> and <code>RewriteLogLevel 2</code></p>
  
  <p>[3]</p>
  
  <pre><code>::1 - - [{date}] [xxx][yyy] (2) [perdir /] rewrite 'var/www/html/testing/' -&gt; 'http://localhost:8585/mytesting/'
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] escaped URI in per-dir context for proxy, http://localhost:8585/mytesting/ -&gt; http://localhost:8585/mytesting/
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] forcing proxy-throughput with http://localhost:8585/mytesting/
  ::1 - - [{date}] [xxx][yyy] (1) [perdir /] go-ahead with proxy request proxy:http://localhost:8585/mytesting/ [OK]
  </code></pre>
  
  <p>[4]</p>
  
  <pre><code>::1 - - [{date}] [xxx][yyy] (2) [perdir /] rewrite 'var/www/html/testing/goodOne' -&gt; 'http://localhost:8585/mytesting/goodOne'
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] escaped URI in per-dir context for proxy, http://localhost:8585/mytesting/goodOne -&gt; http://localhost:8585/mytesting/goodOne
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] forcing proxy-throughput with http://localhost:8585/mytesting/goodOne
  ::1 - - [{date}] [xxx][yyy] (1) [perdir /] go-ahead with proxy request proxy:http://localhost:8585/mytesting/goodOne [OK]
  </code></pre>
  
  <p>[5]</p>
  
  <pre><code>::1 - - [{date}] [xxx][yyy] (2) [perdir /] rewrite 'var/www/html/testing' -&gt; 'http://localhost:8585/var/www/html/testing'
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] escaped URI in per-dir context for proxy, http://localhost:8585/var/www/html/testing -&gt; http://localhost:8585/var/www/html/testing
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] forcing proxy-throughput with http://localhost:8585/var/www/html/testing
  ::1 - - [{date}] [xxx][yyy] (1) [perdir /] go-ahead with proxy request proxy:http://localhost:8585/var/www/html/testing [OK]
  </code></pre>
  
  <p>[6]</p>
  
  <pre><code>::1 - - [{date}] [xxx][yyy] (2) [perdir /] rewrite 'var/www/html/' -&gt; 'http://localhost:8585/var/www/html/'
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] escaped URI in per-dir context for proxy, http://localhost:8585/var/www/html/ -&gt; http://localhost:8585/var/www/html/
  ::1 - - [{date}] [xxx][yyy] (2) [perdir /] forcing proxy-throughput with http://localhost:8585/var/www/html/
  ::1 - - [{date}] [xxx][yyy] (1) [perdir /] go-ahead with proxy request proxy:http://localhost:8585/var/www/html/ [OK]
  </code></pre>