title: Redirect old domain to new domain keeping url
body: <p>We are releasing a new version of our Web app and in the process doing a branding change with a new domain also.</p>
  
  <p>Both our apps are hosted in Azure.
  Current App - Cloud Service
  New App - Azure Website</p>
  
  <p>What I want to achieve is redirect any old links from the old domain to the new domain while keeping the url portion.</p>
  
  <p>Example:
  User visits
  <a href="https://my.currentdomain.com/any/link" rel="nofollow">https://my.currentdomain.com/any/link</a></p>
  
  <p>and will be directed to
  <a href="https://my.newdomain.io/any/link" rel="nofollow">https://my.newdomain.io/any/link</a></p>
  
  <p>Do I do a CNAME from currentdomain to newdomain and then a URL Rewrite in my web.config??</p>
  
  <p>Thanks!</p>
  
  <p>Update - I've test this locally and it does what I'm looking for. I'll just point the cname of the old domain to the new domain and this redirect should pick up the links.</p>
  
  <pre><code>&lt;rule name="Redirect to new domain" stopProcessing="true"&gt;
        &lt;match url="^(.*)$" /&gt;
        &lt;conditions&gt;            
          &lt;add input="{HTTP_HOST}" matchType="Pattern" pattern="^olddomain(:\d+)?$" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Redirect" url="https://my.newdomain.io/{R:1}" redirectType="Permanent" /&gt;
      &lt;/rule&gt;
  </code></pre>