I\'m using mod_rewrite to rewrite pretty URLs to a form supported by a Spring 2.5 application.
e.g. /category/cat1?q=x => /controller?category=cat1&
The query can ony be tested with RewriteCond since RewriteRule does only test the URL path. See Jonathan Feinberg’s example how to do that.
But you could also just set the QSA flag and the old query gets automatically appended to the new one:
RewriteRule ^/category/([^/]+)$ /controller?category=$1 [QSA]
Edit In response to your comment to this question: If you want to get the initial requested URI path and query, you need to extract it from the request line (THE_REQUEST variable):
RewriteCond %{THE_REQUEST} ^[A-Z]+\ ([^\s]+)
RewriteRule ^/category/([^/]+)$ /controller?category=$1&_originalUrl=%1 [QSA]
But in most languages there is an environment variable with the very same information.