EDIT by following our comments:
http://foo.com/xyzPage.aspx?barvalue=yehaa http://yehaa.foo.com/, :
<rules>
<rule name="Rewrite subdomains">
<match url="^/?$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.+)\.foo\.com$" />
</conditions>
<action type="Rewrite" url="http://foo.com?barvalue={C:1}" />
</rule>
</rules>
url / - foo.com, http://foo.com?barvalue={C:1}, {C:1} - , foo.com.
, http://foo.com?barvalue={C:1}, .
Rewrite IIS, web.config:
<rewrite>
<rules>
<rule name="Redirect to Subdomains" stopProcessing="true">
<match url="^xyzPage.aspx$" />
<conditions>
<add input="{QUERY_STRING}" pattern="^barvalue=(.+)$" />
</conditions>
<action type="Redirect" url="http://{C:1}.{HTTP_HOST}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
, url xyzPage.aspx ( ).
, querystring barvalue ( ), .
2 , Redirect http://barvalue.original.host.
Rewrite, , , , type="Redirect" type="Rewrite".
. , , - Rewrite .