Surendra Sharma

Surendra Sharma

Search This Blog

Saturday, September 12, 2015

How to point different URL of same website to single domain name in ASP.NET

If you are implementing Google analytics, Google treats and as different website and give different analytics reports. But in original both sites are same.

Now your client demanding that both URL and should redirect to single URL as

How to solve this?

You must have URL Rewrite module in IIS for this. If you have not then download and install from

Now make entries in web.config between <system.webServer> … </system.webServer> tag by specifying old URL lists mapping with new single URL. Finally your config file entry looks like

      <rule name="CanonicalHostNameRule1">
          <match url="(.*)" />
              <add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
          <action type="Redirect" url="{R:1}" />

You can do all these activities from IIS as well and IIS will make entry in web.config for you.

Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment