When you change the domain name for your website, you are definitely going to solve the migration problem. You cannot just stop DNS on your old domain, because this will cause your indexed pages to be 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 accesses an old URL, redirect it to the new URL.

Take my blog as an example, my old domain is d******, the new domain name is So, for requests to the old domain, 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:

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="^d*******$" />
				<action type="Redirect" url="{R:1}" />

The pattern is using a regular expression, to check if {HTTP_HOST} is equal to d*******

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:

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.