If it's ok I'd like to tag along and add my own question to this.. Basically I'm in the same boat, I tried to use your example and modify it for my case but I can't seem to get it to work as a Rewrite..while it does write out correctly as a Redirect . When I try it as a rewrite I receive a "Bad Request" message..
I'm trying to setup dev environments, and the way that I have to set up the server is.
module.username.server.dns.com so.. basically.. testmod.mikesmith.devbox.companyname.com, and I need it to rewrite to
mikesmith.devbox.companyname.com/testmod
I've set up a Proxy site with no bindings, and a site named mikesmith.devbox.companyname.com
With the follow (and set to redirect) it works perfectly. Redirecting to mikesmith.devbox.companyname.com/testmod
<rule name="Proxy by host" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*)\.([^.]+\.devbox\.companyname\.com)$" />
</conditions>
<action type="Rewrite" url="http://{C:2}/{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
Yet when I change it to rewrite (as seen above).. it flops. I am new to regular expressions, and rewrites so any help would be great.