title: Friendly URL may contain or not parameter
body: <p>I have a frindly(not so much but fits me well) URL expression on my HTACCESS.
  The page treats accordly with "mode" and ids</p>
  
  <p>For editing a category:</p>
  
  <pre><code>#URL
      edit.php?mode=cat&amp;cat=1
  #The expression
      RewriteRule ^editar/([^/]*)/([^/]*)$ /edit.php?mode=$1&amp;cat=$2 [NC,L]
  #Output
      /editar/cat/1
  </code></pre>
  
  <p>Editing subcategory:</p>
  
  <pre><code>#URL
      edit.php?mode=subcat&amp;cat=1&amp;subcat=1
  #The expression
      RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&amp;cat=$2&amp;subcat=$3 [NC,L]
  #Output
      /editar/subcat/1/1
  </code></pre>
  
  <p>Editing product:</p>
  
  <pre><code>#URL
      edit.php?mode=prod&amp;cat=1&amp;subcat=1&amp;prod=1
  #The expression
      RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&amp;cat=$2&amp;subcat=$3&amp;prod=$4 [NC,L]
  #Output
      /editar/prod/1/1/1
  </code></pre>
  
  <p>So far, so good!</p>
  
  <p>But I have three expressions for the same page.</p>
  
  <pre><code>RewriteRule ^editar/([^/]*)/([^/]*)$ /edit.php?mode=$1&amp;cat=$2 [NC,L]
  RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&amp;cat=$2&amp;subcat=$3 [NC,L]
  RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&amp;cat=$2&amp;subcat=$3&amp;prod=$4 [NC,L]
  </code></pre>
  
  <p>Is there any way to reduce that to just ONE expression, where some varible might be or might no be present on the string?</p>
  
  <p>Like: edit.php?mode=prod&amp;cat=1   THIS -> &amp;subcat=1 AND THIS -> &amp;prod=1 being optional?</p>
  
  <p>Thanks!</p>