You can use this rule to 301 redirect site.com/hello-world/?folder=c
=> site.com/a/hello-world/
RewriteCond %{THE_REQUEST} \s/+([^?]+)\?folder=([^\s&]+) [NC]
RewriteRule ^ /%2/%1? [R=301,L,NE]
Just make sure this is placed before your existing rule