RewriteRule ^([^~/]*)(/?)([^~/]*)(.*) /~$3 [P,L]