title: php dynamic URL rewrite with a form submit to clean URL
body: <p>I know a lot can go wrong during a URL rewrite, which is why google recommends against converting URL's to clean URLs' if you don't fully understand what you're doing.</p>
  
  <p>I want to ask if this is the correct way to go about this?</p>
  
  <p>I have a site that is structured like so:</p>
  
  <p>www.example.com/index.php?widget=blue&amp;size=10&amp;weight=50</p>
  
  <p>I am using the mod_rewrite to make it so a clean URL could be used like:</p>
  
  <p>www.example.com/blue/10-inches/50-grams/</p>
  
  <p>I've accomplished this with the following code:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule    ^([a-zA-Z-]+)/([0-9-]+)-inches/([0-9-]+)-grams/?$    index.php? widget=$1&amp;size=$2&amp;weight=$3    [NC,L] 
  </code></pre>
  
  <p>that makes this portion work..  however there's a form on the index page as well that changes the products on the index.php page based on the drop down box selections and the submit button being pressed.</p>
  
  <pre><code>Dropdown 1 = blue, red, green
  Dropdown 2 = 10, 20, 30
  Dropdown 3 = 25, 50, 100
  </code></pre>
  
  <p>What happens here by default is when you select say, red, 20, 100 and click submit, you'll get the old URL like  www.example.com/index.php?widget=red&amp;size=20&amp;weight=100</p>
  
  <p>How could I do the redirection here? I'm currently working on doing it this way:</p>
  
  <p>Change the <code>&lt;form action="index.php" method="GET"&gt;</code>  to <code>&lt;form action="redirect-url.php" method="GET"&gt;</code></p>
  
  <p>That new redirect-url.php will have the following code:</p>
  
  <pre><code>&lt;?php
      header('Location: www.example.com/'.$_GET[widget].'/'.$_GET[size].'/'.$_GET[weight].'/');
      exit();
  
  ?&gt;
  </code></pre>
  
  <p>Which should cause the apache RewriteRule I posted above to make it work.</p>
  
  <p>Thoughts? Will this work? Is there a cleaner way?</p>