How would I mod_rewrite "/~a1Pha" and "/=a1Pha" to "/paste/a1Pha.htm"? (internally & externally)

Basically I want to shorten URLs on my html pasting site (pasteht.ml), by using "/~a1Pha" instead of "/paste/a1Pha". The ID is 5 numbers and letters, both cases.

For example:
/~idnum serves /paste/idnum.htm
/=idnum serves /paste/idnum.htm
/paste/idnum redirects to /~idnum (to update any old urls to new ones)

I have mod_rewrite enabled and working.

Edit: Figured it out:

RewriteRule ^~?([a-zA-Z0-9]+)$ paste/$1.htm [L]
RewriteRule ^=?([a-zA-Z0-9]+)$ paste/$1.htm [L]