Changing from one domain to another in IIS

We recently had a client running IIS change primary domains but they wanted to keep the old domain active. One of their web application didn’t like having the old domain URL active, so we had to create an IIS rewrite rule. I have included it below, with the URLs changed to a couple that we control.

<rewrite>
   <rules>
      <rule name="Canonical Host Name" stopProcessing="true">  
      <match url="(.*)" />  
         <conditions>  
	    <add input="{HTTP_HOST}" pattern="^pctechrescue\.com$" />  
	 </conditions>  
      <action type="Redirect" url="http://techrescue.mn/{R:1}"redirectType="Permanent" />
      </rule>
   </rules>
</rewrite>

This takes any link that has “pctechrescue.com” as the prefix and automatically rewrites it to have “techrescue.mn” as the prefix, thereby saving any bookmarks or direct links out there.

For instance:
http://pctechrescue.com/category/techtalk/ is automatically changed to:
http://techrescue.mn/category/techtalk/.

Leave a Reply

Your email address will not be published. Required fields are marked *