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:
http://campbellssweets.com/shop/popcorn/product.php?subject=Bacon+and+Cheddar+Popcorn
I have 2 questions:
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?
2) Similarly, how might I go about replacing the '+' with dashes so that the final URL is displayed as:
http://campbellssweets.com/shop/popcorn/Bacon-and-Cheddar-Popcorn
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.
I really appreciate the help!
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
I have a category page that lists all of the items in the database via a loop. The page is saved as index.php:
/shop/popcorn/index.php
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:
<a href="product.php?subject=<?php echo urlencode($list_savory["product_name"]); ?>">
The product page URL's (which are the focus of this question), were displaying as:
shop/popcorn/product.php?subject=Bacon+and+Cheddar+Popcorn
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:
shop/popcorn/Bacon-and-Cheddar-Popcorn
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.
I hope that helps clear everything up. Sorry again for the confusion, I'm new at this.