title: Regex for htaccess that matches multiple words split by hyphen
body: <p>For now I'm using this htaccess file in my e-shop script:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([\w-]+)/([\w-]+)/?$ product.php?category_id=$1&amp;product_id=$2 [QSA,L]
  RewriteRule ^([\w-]+)/?$ products.php?category_id=$1 [QSA,L]
  </code></pre>
  
  <p>It seems SEO friendly and is allowing customer to see nicely printed address bar like:</p>
  
  <p><code>mydomain.com/CDPlayers/Sonytr200</code></p>
  
  <p>The problem is that I was told to improve engine so instead of <code>CDPlayers</code> or <code>Sonytr200</code> I should produce <code>CD-Players</code> and <code>Sony-tr-200</code>. I have to admit that I got that htaccess regex from the web, because I didn't study regex much.</p>
  
  <p>This one isn't working anymore due to fact that it is accepting only one word and now I need something that will allow me to use unlimited number of words split by hyphen so it has to work in following cases:</p>
  
  <ul>
  <li><code>mydomain.com/Word</code> (stage 1)</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li><code>mydomain.com/Word-word-word</code> (stage 1)</li>
  </ul>
  
  <p>and</p>
  
  <ul>
  <li><code>mydomain.com/Word/Word</code> (stage 2)</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li><code>mydomain.com/Word-word-word/Word-word-word</code> (stage 2)</li>
  </ul>