I think this can be done, but it’s kinda silly, because users who type in the “real” (not “old”, you need to think of these as real and fake, not new and old) url (the one with the query string) will get redirected to a pretty url who, because he is not real, gets rewritten back to the real url. It’s a bit of a punishment for users and your server, I think, getting redirected around. Esp since, if they click on anything on this page, they get the fake urls from there on.
Instead, you spread your “pretty” urls around the web as much as possible. The point of a rewrite is really that you could change your url to something you liked, without a) changing the real original resource location or name and b) not breaking old backlinks.
In fact I believe what we did was add [L,R=301] to our rewrites to tell for example search engines that our rewrite was a permanent “new” url and to use the new pretty one from now on. This didn’t stop typing in the “real” url from working, but it meant pretty much everywhere, the new one was what users found.
But, if I were to try it anyway, I’d try this (I don’t know if it works with two vars and = and & in there)
RewriteCond %{QUERY_STRING} ^?variable1=x&variable2=y$
RewriteRule ^$ /variable1/variable2? [L] <– notice “^$” means there’s nothing between your domainname and the query string, so domainname.com/?querystring works, not domainname.com/something/?querystring
but the rewriteCond would have to be exact, unless the variable names are the same and you just want to change the numbers, you could (I think)
RewriteCond %{QUERY_STRING} ^variable(1)=x&variable(2)=y$
RewriteRule ^$ /variable%1/variable%2?
Again, this is kinda something pulled out of my butt so I haven’t tested it and I’ve only seen examples where there’s a single var in the query string, not multiple strung together with &'s, so may break horribly. I’m also not adding [L] after the rewrite since you need to rewrite that new url again back to the real one.
Normally with rewrites, query strings are kept (not rewritten) and tacked on to new urls… so I’ve got a ? at the end of the rewrite rule to set ? to “nothing”.