title: Rewrite URL in .htaccess - PHP
body: <p>I have a problem with <code>.htaccess</code> file and code in that file. I create a simple CMS using PHP. In Fron-End users can view listed products and buy the same. Where is the problem? The problem is when listed product on <code>localhost/site3/index.php</code> and the open random product you can view all information about that project, but when the user opens category <code>products/protection-program/inspection-gloves/index.php</code> and on that page click on a random product then user get an error <strong>The requested URL was not found on this server</strong>. How to generate <code>.htaccess</code> file to support the next URLs.</p>
  
  <p>My <code>.htaccess</code> file:</p>
  
  <pre><code>RewriteEngine On
  RewriteRule ^([0-9A-ZA-Z-]+)$ details.php?pro_id=$1 [QSA,NC,L]
  </code></pre>
  
  <p>File <code>details.php</code> write-in <code>.htaccess</code> the file is stored into <code>localhost/site3/details.php</code>. In that file is written code for preview all product information. </p>
  
  <p>I try next: </p>
  
  <ol>
  <li><p>Copy and Paste <code>details.php</code> file into <code>localhost/site3/products/protection-program/inspection-gloves/details.php</code> and then open some products listed in that category, but won't work.</p></li>
  <li><p>Change <code>RewriteRule ^([0-9A-ZA-Z-]+)$ details.php?pro_id=$1 [QSA,NC,L]</code> to <code>RewriteRule ^([0-9A-ZA-Z-]+)/([0-9A-ZA-Z-]+)/([0-9A-ZA-Z-]+)$ details.php?pro_id=$1 [QSA,NC,L]</code>. With this change when open random product stored on next URL <code>localhost/site3/products/protection-program/inspection-gloves/</code> i get automaticly redirection to <code>localhost/site3/index.php</code>. Don't know reason.</p></li>
  </ol>
  
  <p><strong><em>Note: I have some products with less or more categories/sub-categories...</em></strong></p>
  
  <p>I want to generate <code>.htaccess</code> to support all my URLs. Any advice or help will be helpful. Thanks all!</p>