When you are changing the domain name for your website, you are definitely going to solve the migration problem. You can not just stop DNS on your old domain, because this will cause your indexed pages being deleted by search engines. The correct way is to tell the search engine that you have a new domain name now, which is when the user access an old URL, redirect it to the new URL.

Take my blog as an example, my old domain is diaosbook.com, the new domain name is edi.wang. So basically for requests to the old diaosbook.com, such as:


I need to redirect it to:


Which is just replace the domain name and keep everything else in the URL.

To implement this feature, we need to install the URL Rewrite module on IIS: http://www.iis.net/downloads/microsoft/url-rewrite

For every website managed by IIS, it can assign URL rewrite or redirect rules individually. You can use both GUI and manually edit web.config to modify the rules.

My configuration for migrating the domain name would be:

			<rule name="CanonicalHostNameRule">
				<match url="^(.*)$" />
					<add input="{HTTP_HOST}" pattern="^diaosbook.com$" />
				<action type="Redirect" url="http://edi.wang/{R:1}" />

The pattern is using a regular expression, to check if {HTTP_HOST} is equal to diaosbook.com

the {R:1} in the action means whatever is in the URL behind the domain name itself.

We have two types: Redirect and RewriteRedirect will result in an HTTP 301, which will notify the search engine about the domain change, while Rewrite will just keep the HTTP status code, for example, you have a "/a/b/c.html" and rewrite into "/d.html", then Rewrite will just make it looks like you are accessing /d.html, and its content is output using c.html.

If you have other rules, mind the order, they are being processed from top to bottom.

You may refer to Microsoft documentation for more usage: http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

Now, we can get a 301 redirection, the search engine will also update their index. After a couple of months, you can stop DNS on your old domain.