Forum Moderators: open
http://www.example.com/products/Laser-Printers/259040/HP-LaserJet-P2055DN-35ppm-1200dpi-Network-Laser-Printer
Essentially, use the category, the sku, and then title as the URL?
But before you get started, you don't change the url from query string to keyword-url, it's the other way around. You create "friendly URL's" on the site and in your product feeds, and redirect/rewrite them accordingly. So if you have a directive like so,
RewriteRule ^some-non-existent-url(.*) /path/to/script.php
This would make any request to your domain that begins with "some-non-existent-url" to rewrite to script.php - while the address bar remains as "some-non-existent-url". Then script.php is what parses out and manages the URL.
Example:
example.com/some-non-existent-url/laser-printers/deskjet
script.php receives this as $_SERVER['REQUEST_URI']. You then split the URI on slashes,
$params = explode('/',$_SERVER['REQUEST_URI']);
Then pop the ones off you need.
$product = array_pop($params);
$category = array_pop($params);
So now you have 'laser-printers' and 'deskjet'. To insure your "old" query strings still work, you can do something like this:
$product=(isset($product))?$product:$_GET['product'];
$category=(isset($category))?$category:$_GET['category'];
Then you'd do
$product=preg_replace('/\-/',' ',$product);
$category=preg_replace('/\-/',' ',$category);
select * from table where product_title='$product' and category='$category';
You will have to work out some logic converting these to numeric values if that's what you're using now, but that's the gist. Another approach is to store "URL" as a field in the database, and look for that value instead.
Now your program can continue as it normally does, without major changes, because you've checked for the URI first, if it's present, use it, otherwise, look for the usual values in $_GET.
This way old query strings will still work, but you can begin porting to friendly URL's fairly quickly.
[edited by: rocknbil at 6:27 pm (utc) on Nov. 30, 2009]