301 Redirects on IIS A Tale of Two URLs

301 Redirects on IIS A Tale of Two URLs

Most websites, including mine, have the same content for their domainname as well as for www+their domain name. For instance at my site in the past if you went to jdhodges.com you’d get the same thing as www.jdhodges.com. The problem with this is that Google and other search entries treat www.yourdomain.com and yourdomain.com as two completely different sites, this can result in your pagerank being split between multiple sites and duplicate content showing up on the search engines.

Here is how to make sure that www.yourdomain.com is the only address people and search engines will ever get even if they try to access yourdomain.com without the www.

Do a 301 redirect via the IIS management console and “A redirection to a URL”

For this exampledomain to perform the redirect we do the following

  1. Open Internet Services Manager and create a web site for exampledomain.com
    1. Make the content directory for the site exampledomain.com the same directory, i.e. c:\inetpub\wwwroot, that you use for your www domain i.e. www.exampledomain.com
  2. Test loading a page from http://exampledomain.com this should work because we haven’t setup the redirect yet.
  3. Open exampledomain.com site in Internet Services manager.
  4. Go to the properties of the exampledomain.com site
  5. Go to the Home Directory tab:
  6. Change the option button “When connecting to this resource the content should come from” to "A redirection to a URL"
  7. Enter your full URL http://www.exampledomain.com
  8. Check the checkbox that says “A permanent redirection for this resource.”
  9. Your screen should look something like this:

301 Redirect via ASP code

If you don’t have access to the IIS management console or you want to do it on a specific ASP page, here is the ASP code to insert:

<%
Response.Status = "301 Moved Permanently"
Response.addheader "Location", "http://www.yourdomain.com/"
Response.End
%>

You would put that code in the default.asp document (or whatever your asp index file is) that is in the root directory of yourdomain.com server, when people type that domain in their browser it will load your default.asp file and run the redirect code which will take them to www.yourdomain.com

Comments:

 

1. Stewart commented on 11/23/2003 2:18:25 PM:

This is interesting. I thought Google and the others would treat the URLs the same (assuming you did an A record for the short, and a CNAME pointed at A for “www.”). I looked around and can’t find any info on this — do you have one?

I tried “link:vardaman.org” and “link:www.vardaman.org” at Google and got identical results. But it appears that evey site linking to me uses “www.”

I’ve noticed a lot of SE’s are really sloppy on 301 redirs. I moved from .ASP to .PHP well over a year ago, and used mod_rewrite to 301 them, but some like AllTheWeb still show .ASP.

Stewart Vardaman

2. J.D. commented on 11/23/2003 7:20:08 PM:

With totally different domains pointing to the duplicate content, Google will penalize after a point. So you are right Stewart that Google must treat specially domains with www and non-www pointing to the same thing, otherwise half off the sites out there would be getting penalized for duplicate content.
If you look at the two URLs of a page like my friend Ronnie at www.ronniewilliams.net and ronniewilliams.net then the PageRanks (viewed via the Google toolbar) will be different. Another example, before my 301 redirect, jdhodges.com used to have a PR1 and www.jdhodges.com PR of 5.
You came up with a great solution Stewart, in using CNAMEs but no one really knows what google does with the issue, and I don’t think they do CNAMEs because otherwise I would expect the same PR from both www and non-www.

3. Stewart commented on 11/24/2003 1:11:29 AM:

Thanks for the info! I personally haven’t looked at my PR (never installed the Google Toolbar), but it’s something I should be paying attention to.

I noticed this a bit later: I happened to recall that many links I see to Reason magazine have WWW left off. So I tried “link:” queries at Google:

link:reason.com = 3,260 results
link:www.reason.com = 4,450 results

There’s some duplication between the two, but WOW.

Your 301 redirect solution is a good practice is well worth adopting.

Also on this subject, NPR has the stupidest method:

http://npr.org/

They use Javascript to redirect to WWW. Some 14% of internet users have JS disabled:

http://www.thecounter.com/stats/2003/May/javas.php

And robots like googlebot obviously are going to choke on JS.

Thanks again for the idea!

4. Ronnie commented on 11/24/2003 3:27:26 PM:

I never noticed I had 2 page ranks.. is there a solution for those who do not host their website on servers they control to fix this?

5. J.D. commented on 11/24/2003 3:31:02 PM:

You could actually point your DNS cname records for ronniewilliams.net to someone else’s server, and let them host the 301 redirect back to your www.ronniewilliams.net page. Let me know if you want me to do that Ronnie.

6. Stewart commented on 11/27/2003 2:48:50 PM:

FYI if you’re running Apache you can do this with mod_rewrite (in the main config if you control the server, or .htaccess if you have shared hosting). Mine looks like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^vardaman.org$
RewriteRule ^(.+) http://www.vardaman.org/$1 [L,R=301]

This takes care of subdirs too (http://site.com/stuff/here/there.html)

7. mike commented on 4/10/2004 11:31:06 PM:

I understand different URLs with the same domain can have different pageranks, because they are allowed to be different sites. Sometimes by coincidence ranks are the same: compare www.house.info and plain
house.info ). I have some questions I hope you can answer. Is it necessary to have a
unique IP number dedicatedd to your domain and site in order to have good pagerank?
How can high PR domains can be used to increase rank of another site, without developing a site? Redirection doesn’t help. Does CName help? Last question: If
CName doesn’t resolve to intended domain and instead resolves to a different domain hosted on the same server, what can one conculde in terms of PR?

8. mike commented on 4/10/2004 11:31:07 PM:

Above I meant compare http://www.house.info and http:// house.info, sorry for confusion.

9. MonIca KEndal commented on 4/10/2004 11:31:08 PM:

I meant h.i.

10. J.D. commented on 4/13/2004 11:31:06 PM:

Hi Mike, good questions and observations Smiley

You’re right about pages (URLs) having the same PageRank seemingly “by coincidence” but you should be able to determine fairly precisely WHY each URL has a certain PR.

The most useful way I know to analyze why a URL has a high or low PR is to look at the backlinks of the URL (backlinks are the pages that point “back” to the URL you’re viewing.)

Different search engines will have different sets of backlinks, and the methods for determing baclinks varies. I wrote the Googlizer to check backlinks or search engine saturation (saturation indicates how many pages from a particular domain are indexed in a search engine, i.e. how “saturated” the search engine is with that domain.)

If two URLs have the same PR, then each URL should theoretically have a similar number or quality of inbound links (backlinks)

An example of this, say widget1.com has TEN PR5 backlinks and www.widget1.com has ONE PR6 backlink. Both widget1.com and www.widget1.com may both end up having a PR4 or PR5 (the point is that inbound PR quality as well as quantity plays a role in determining PR.) If this wasn’t clear, just post and we’ll try to do some better examples Smiley

I don’t think CNAME will help. The easiest way to transfer PR is via a text link. The link should be FROM the high PR page and TO the low PR page.

Can you give me a specific example on the last question you had (about cname not resolving…)

11. mike commented on 4/14/2004 11:31:06 PM:

Thanks for answers. Maybe I should ask last one in a different way. Two domains and their sites are hosted on one server:
site A, and site B. Site B is mine. Webhoster told me that site B doesn’t have unique IP resolving to site B. If I Cname another domain, say C, to B; it is redirected to A. I am wondering if I (site B) am losing any rank because of this situation.

Leave a Reply

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