I would simply like to rewrite all requests from:
http://example.com/products/product.cfm?id=product-name
to
http://example
Something along these lines:
RewriteCond %{query_string} &?id=([^&]+) [NC]
RewriteRule ^/products/product.cfm$ /products%1? [R,NC,L]
# Fragile, this assumes that params will always be in order id= then sub=
RewriteCond %{query_string} &?id=([^&]+)&sub=([^&]+) [NC]
RewriteRule ^/category.cfm?$ /%1/%2? [R,NC,L]
The R flag in the RewriteRule forces a hard redirect (the visitor's location bar will change to the new URL). Remove this flag for an internal redirect.
Using mod_rewrite
, you could write:
RewriteRule ^products/([\w-]+)$ /products.cfm?id=$1&%{QUERY_STRING}
This will do the translation you wanted, while preserving other parameters in the original URL. It won't handle categories, but I'm not sure you can have those both in operation simultaneously as you described.
http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
I don't like pure "link" answers, but the link above is extremely helpful to me :]