I have what to me seems like a simple task with IIS URL Rewrite.
I need to redirect based on sub-domains to a main domain with a query string. For example
demo.domain.com needs to be redirected to www.domain.com/?key=demo
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="demo.domain.com" />
</conditions>
<action type="Redirect" url="www.domain.com/?key=demo" appendQueryString="false" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>