Forum Moderators: phranque
Some of my urls have commas and spaces in the query string.
Example:
http://example.com/folder.php?product=These are, keywords
which results in:
http://example.com/folder/These are, keywords
How can I change the commas and spaces or other characters to hyphens?
[edited by: jdMorgan at 11:00 pm (utc) on July 29, 2009]
[edit reason] example.com [/edit]
But after you do that, and the visitor clicks on a link "example.com/folder/These-are-keywords" your mod_rewrite code will rewrite that to the path "/folder.php?product=These-are-keywords", and you will need to use relatively-complex PHP code to find a "best match" for that hyphenated version in the database if the database still contains/uses the "These are, keywords" format.
So your best bet is to fix this in the database itself.
Sometimes site owners just choose to edit the "These are, keywords" entry itself. Sometimes they choose to create and additional entry, so that the product and/or page description becomes a separate item from the string used in the URL. Wearing both a coder hat and an SEO hat, that is what I would do. In fact, I'd make just about *everything* a separate value in the database record for a product, and if I really felt I needed to re-use the exact same text for page description, product description, and keyword-URL-string, I'd do a copy and paste inthe database entry form, and so be it.
Jim
Because of that, you'll find several contemporary threads here about getting rid of extensions.
Jim