title: problems working with 'rewrite' in apache2
body: <p>I have the following list of URLs to rewrite:</p>
  
  <p>1 write url<br />
    /products/<strong>client</strong>/</p>
  
  <p>send to<br />
    /basedir/system/index.php?client=<strong>cliente</strong></p>
  
  <p>2 write url<br />
    /product/<strong>client</strong>/index.php</p>
  
  <p>send to<br />
    /basedir/system/index.php?client=<strong>cliente</strong></p>
  
  <p>3 write url<br />
    /products/<strong>client</strong>/image/dir2/myimage.jpg</p>
  
  <p>send to<br />
    /basedir/system/image/<strong>client</strong>/dir2/myimage.jpg</p>
  
  <p>4 write url<br />
    /products/<strong>client</strong>/image/dir2/more_x_dir/other.img</p>
  
  <p>send to<br />
    /basedir/system/image/<strong>client</strong>/dir2/more_x_dir/other.img</p>
  
  <p>With these rules I have more or less solved the points 1 and 2: </p>
  
  <pre><code> RewriteEngine On
  
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
  
   RewriteRule ^product/([a-zA-Z]+)$ /basedir/system/index.php?client=base=$1 [L,QSA]
   RewriteRule ^product/([a-zA-Z]+)/$ /basedir/system/index.php?client=base=$1 [L,QSA]
   RewriteRule ^product/([a-zA-Z]+)/(.*)$ /basedir/system/index.php?client=$1 [L,QSA]
  </code></pre>
  
  <p>My problem is in cases 3 and 4 when I have files with css / image's / js. and also when I have many directories, it may be that in the case of many directories have to make a rule for everyone, but I do not know how.</p>
  
  <p>thank you very much</p>
  
  <p><strong>Edit</strong></p>
  
  <p>my solution based on the answer accepted:</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  RewriteRule ^product/([a-zA-Z]+)/(.*)\.(gif|jpg|ico|css|js|txt|zip|xls|doc)$ /basedir/system/$2.$3 [L,QSA]
  RewriteRule ^product/([a-zA-Z]+)$ /basedir/system/index.php?database=$1 [L,QSA]
  RewriteRule ^product/([a-zA-Z]+)/$ /basedir/system/index.php?database=$1 [L,QSA]
  RewriteRule ^product/([a-zA-Z]+)/index.php$ /basedir/system/index.php?database=$1 [L,QSA]
  RewriteRule ^product/([a-zA-Z]+)/(.*)$ /basedir/system/$2?database=$1 [L,QSA]
  </code></pre>