I managed to solve it with this:
RewriteCond %{THE_REQUEST} /([^/]*)/([^/]*)/([0-9a-zA-Z]*)\.htm?(.*)cid=([0-9a-zA-Z]{8}) RewriteRule ^ /%1/%2/%3-%5.htm [R=301,L,QSA]
Mods please close if irrelevant