title: Formatting .htaccess RewriteCond / RewriteRule for removing query string from URLs
body: <p>I have developed a PHP site, which uses _GET variables to construct individual product pages. The current structure of the URLs for the (live) site is as follows:</p>
  
  <p><a href="http://campbellssweets.com/shop/popcorn/product.php?subject=Bacon+and+Cheddar+Popcorn" rel="nofollow">http://campbellssweets.com/shop/popcorn/product.php?subject=Bacon+and+Cheddar+Popcorn</a></p>
  
  <p>I have 2 questions:</p>
  
  <p>1) What is the proper way to construct the RewriteCond and/or RewriteRule in my .htaccess file to remove the 'product.php' and the query string from the example above?</p>
  
  <p>2) Similarly, how might I go about replacing the '+' with dashes so that the final URL is displayed as:</p>
  
  <p><a href="http://campbellssweets.com/shop/popcorn/Bacon-and-Cheddar-Popcorn" rel="nofollow">http://campbellssweets.com/shop/popcorn/Bacon-and-Cheddar-Popcorn</a></p>
  
  <p><em>For what it is worth, I am utilizing the 'index.php saved in a sub-folder' method to remove the '.php' from the category pages.</em></p>
  
  <p>I really appreciate the help!</p>
  
  <p><strong>I have added the current work flow below to hopefully better explain my question. Apologies if I am doing something wrong here, it's my first post</strong></p>
  
  <p>I have a category page that lists all of the items in the database via a loop. The page is saved as index.php: </p>
  
  <pre><code>/shop/popcorn/index.php
  </code></pre>
  
  <p>Each of the items listed in the category page link to individual product pages (product.php), which is in the same directory as the category page. The (product.php) page is dynamic and its content is dependent on the value of the $_GET variable: The link from main category page that generates the product.php page is as follows:</p>
  
  <pre><code>&lt;a href="product.php?subject=&lt;?php echo urlencode($list_savory["product_name"]); ?&gt;"&gt;
  </code></pre>
  
  <p>The product page URL's (which are the focus of this question), were displaying as:</p>
  
  <p><strong>shop/popcorn/product.php?subject=Bacon+and+Cheddar+Popcorn</strong></p>
  
  <p>I was trying to figure out the correct .htaccess code that would remove query string from the URL and replace the '+' with dashes so they would instead display as: </p>
  
  <p><strong>shop/popcorn/Bacon-and-Cheddar-Popcorn</strong></p>
  
  <p>Ravi's answer does format the URL'S in the way that I requested, but the page fails to load and I get a '404 Not Found' error - even after I successfully modified the product.php conditional to accept the $_SERVER['REQUEST_URI'] instead of the $_GET variable.</p>
  
  <p>I hope that helps clear everything up. Sorry again for the confusion, I'm new at this. </p>