title: Reference rewriterule matched group in a rewritecond regex?
body: <p>I am using Apache's mod_rewrite module. Is there a way to reference a group captured by <code>RewriteRule</code> within the regex of <code>RewriteCond</code>?</p>
  
  <p>For example:</p>
  
  <pre><code>RewriteCond %{REQUEST_URI} ^(.*(?=/#How can I 'paste' $1 = RewriteRule's (.*) group here?#$))
  RewriteRule ^(.*)$ - [E=BASE_PATH:%1]
  </code></pre>
  
  <p>Here I will match the base path of the request URI, for example, if I request <code>mysite.domain/subdir/my/site/dir</code>, and <code>.htaccess</code> is inside <code>subdir/</code> then:</p>
  
  <pre><code>1) RewriteRule ^(.*)$ ----&gt; ^(my/site/dir)$ -----&gt; $1 = my/site/dir
  2) RewriteCond /subdir/my/site/dir ^(.*(?=/#I need to 'paste' the $1 RewriteRule's matched group here#$))
  </code></pre>
  
  <p>How can I do that so that my RewriteCond regex is generated 'dynamically' and becomes:</p>
  
  <blockquote>
    <p>^(.*(?=/<strong>my/site/dir</strong>$))</p>
  </blockquote>
  
  <p>Where <strong>my/site/dir</strong> is what was matched in RewriteRule's $1 group?</p>