title: mod_write RewriteRule
body: <p>im sure this is simple but i totally cant get it to work :\
  I'm trying to rewrite</p>
  
  <p><code>http://www.example.com/products/ABC123</code></p>
  
  <p>to</p>
  
  <p><code>http://www.example.com/index.php?page=shop&amp;code=ABC123</code></p>
  
  <p>I have tried</p>
  
  <pre><code>RewriteBase /
  
  RewriteRule ^products/([A-Za-z0-9]+)$ index.php?page=shop&amp;code=$1
  </code></pre>
  
  <p>Which redirects OK but all the images (and js css etc) have the wrong path (example.com/images/ABC123.jpg is example.com/products/images/ABC123.jpg). Also all of the links are now the wrong path (example.com/?page=shop&amp;folder=7 is example.com/products/?page=shop&amp;folder=7)</p>
  
  <p>My .htaccess file is in the root, I have also tried RewriteBase products/ and removing products/ from the rules regex but that just throws a 404</p>
  
  <p>I've read the official docs concerning mod_rewrite several times in the last hour, I must be missing something?</p>
  
  <p>** EDIT: **
  Sorry all was a bit of a trick question, turns out you can solve this with the html BASE element, there was nothing wrong with my regex at the start!</p>
  
  <p>I put &lt;base href="http://www.example.com/" /&gt; in the HEAD section and it's all fine and dandy now!</p>
  
  <p>Thanks to the guys who showed me how to set conditions for weather or not the file/directory exists</p>