title: How to redirect all links with specified subdomain to its root domain
body: <p>I need help with writing a URL Redirect rule on IIS 7.5</p>
  
  <p>I need to create a rule so if someone visits the site <code>this-sub.example.com/anything</code> then he would be redirected to the <code>example.com</code> page.</p>
  
  <pre><code>&lt;rule name="My redirection home"&gt;
      &lt;match url="(.*)" /&gt;
      &lt;conditions&gt;
          &lt;add input="{HTTP_HOST}" pattern="^this-sub.example.com/*.*" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="http://example.com" appendQueryString="false" redirectType="Permanent" /&gt;
  &lt;/rule&gt;
  </code></pre>
  
  <p>instead of redirecting <code>this-sub.example.com/anything</code> to <code>example.com</code> it redirects to <code>example.com/anything</code>. It keeps the <code>anything</code> part. I have also URL Rewrite module installed.</p>