Something like this may help:
<rewriteMaps>
<rewriteMap name="domains">
<add key="newdomain.com" value="somefolder" />
<add key="anotherdomain.com" value="someotherfolder" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Redirect by domain">
<match url=".*" />
<conditions>
<add input="{domains:{HTTP_HOST}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url=http://mydomain.com/{C:1}/ appendQueryString="false" redirectType="Permanent"/>
</rule>
</rules>
Note that rewrite map lookup is literal, so you cannot use any patterns when specifying domain names in the rewrite map.