title: How to setup optional parameters in mod_rewrite
body: <p>I am in a new project and I'm designing the URL structure, 
  the thing is I want URLs look like this:
  <code>/category-23/keyword/5/</code>
  Where the normal page is:
  <code>/search.php?q=keyword&amp;cat=23&amp;page=5</code>
  So my question is, <em>cat</em> and <em>page</em> fields, must be optional, I mean if I go to <code>/keyword</code> it should be 
  <code>/search.php?q=keyword</code> (page 1)
  and if I go to
  <code>/category/keyword</code> should be:
  <code>/search.php?q=keyword&amp;cat=category&amp;p=1</code>
  and also if I go to
  <code>/keyword/5/</code> it must be: <code>/search.php?q=keyword&amp;p=5</code></p>
  
  <p>Now I have my .htaccess like this:</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule ^(.*)/(.*)/(.*)$ search.php?q=$2&amp;cat=$1&amp;page=$3 [L]
  </code></pre>
  
  <p>I cannot make it working and the CSS / image files don't load.
  I'd thank a lot who could give me a solution.</p>