title: mod_rewrite : if / else type RewriteRule
body: <p>The following rewrite passes a string starting with the number 4 as a variable to process.php :</p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(4[^/]*)$ /process.php?variable=$1 [L]
  </code></pre>
  
  <p>So this</p>
  
  <pre><code>http://www.domain.com/4shopping
  </code></pre>
  
  <p>is mapped to </p>
  
  <pre><code>http://www.domain.com/process.php?variable=4shopping
  </code></pre>
  
  <p>But I want to extend this last rewrite rule to basically state:</p>
  
  <pre><code>if word begins with 4, map to /process.php?variable=$1
  else map to /index.php
  </code></pre>
  
  <p>The second (else) part of this statement is the basic WordPress rewrite rule.  So for example:</p>
  
  <pre><code>http://www.domain.com/shopping
  </code></pre>
  
  <p>which has no 4 will be directed to</p>
  
  <pre><code>http://www.domain.com/index.php?shopping (I believe this is how WordPress permalinks work!)
  </code></pre>