Dotnetplace.com

.NET Articles, Web Devploment, ASP.NET, HTML, Sharepoint 2010, Aamir Hasan
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here

Advertise

Loading...


Posted by Aamir Hasan   on Monday, October 10, 2011 Total Views:  

In this article, I will demonstrate how to redirect non-www domain to www domain. When user writes www.domain.com or domain.com both will open the same content but search engine will treat as two different domain and rank as both domain name if some one visit your site with non-www or www domains. URL rewrites 2.0 gives you canonical domain name rule template that will resolve canonical hostname in your web site. I will extend my previous article IIS 7 URL Rewrite Module 2.0 – Convert to lowercase URL. Let’s start.

Step 1: Open your IIS 7, expand your IIS Sites node, click on your desire website and double click on URL Rewrite extension.

Step 2: Click on Add Rule(s) link from right pane.

Step 3: From Search Engine Optimization (SEO) section click Canonical domain as shown in below.

Step 4: “Add a rule to redirect to a canonical domain name” dialog box will appear and select the primary host name as shown.

The following new created rules shows you in below figure.

Note: this rule force to redirect domain.com to www.domain.com.

The following rule will add in your Web.Config file as shown.

        <rules>

        <rule name="CanonicalHostNameRule1">

          <match url="(.*)" />

          <conditions>

            <add input="{HTTP_HOST}pattern="^www\.domainname\.com$negate="true" />

          </conditions>

          <action type="Redirecturl="http://www.domainname.com/{R:1}" />

        </rule>

      </rules>

Category:
Protected by Copyscape Online Plagiarism Tool

Comments (1) -

http://www.fetr.net
http://www.fetr.net Czech Republic
7/25/2012 8:40:10 PM #

good information

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5