How do I redirect conditionally with query /xxx?xxx in the url link?

For example, anyone who come to my site with the below two link should be redirected to different pages.

mysite.com/contest?a => mysite.com/contest-a   

mysite.com/contest?b => mysite.com/contest-b

Can this be done using both js and meta refresh?

How do I do this using .htaccess?