Surviving the Domain Alias Problem with your Page Rank in tact
 

by Sameera on October 31, 2007 14:14

Few months ago, I ran into a seemingly devastating problem. I had initially started my official online presence Cool with the domain codeofdefiance.com. At that time  the name meant something that kind of died off after a certain project was completed. So, I thought of moving on to this new domain (Codoxide.com). I purchased it and asked my service provider (PlanetSMB.com) to use it with my existing package. They of course, did exactly what I asked them to and planted Codoxide.com as my primary domain and CodeofDefiance.com as an alias to the same. 

As any self-respecting web master would do, I continued to monitor my new domain using Google Analytics and Web Master Tools, and of course the search. After a while, it became obvious that my new domain was not going to get indexed. If I ran a search for very specific keywords that had a high likelihood of hitting, say, www.codoxide.com/posts/pageA.aspx, Google would always show www.codeofdefiance.com/posts/pageA.aspx but not the former. For any experienced web master, problem here would have been obvious. Google had already developed it's relationship with my old domain. For all it knew, Codoxide was some obscure web site mirroring the content of an established site. And I hear, that's a pretty deadly sin in Google's eyes. Such a rookie mistake...

Well, a quick fix for this would have been to take down the old domain name and wait for search engines to pick up the new site. But then, I'd be starting back at zero, if I was to do that. The only good solution was to get search engines to understand that CodeOfDefiance will from then on be Codoxide!

301 To the Rescue

What I needed was to respond to each request for CodeOfDefiance with a "301 Permanent Redirect" response. I asked PlanetSMB whether they could do it. It turned out that they couldn't, which lead me to this workaround. For anybody that might find himself in this situation, here are the steps to follow (I did all this from my site's web admin panel PLESK):

1. Setup a new web application under your site. Let's say the virtual directory you picked was "/redirect"

2. Add a Default.aspx page to site and the following code to it:

[code:c#]
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Status = "301 Moved Permanantly";
        Response.Location = "http://www.codoxide.com/Default.aspx";
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>
[/code]

3. Add an error.aspx page with the following code;

[code:c#]

        try
        {
            string requestedPath = Request.QueryString["aspxerrorpath"];
            Response.RedirectLocation = string.Format("http://www.codoxide.com{0}{1}",
                    requestedPath.StartsWith("/") ? "" : "/",
                    requestedPath);
        }
        catch (Exception)
        {
            Response.RedirectLocation = "http://www.codoxide.com/";
        }

[/code]

This will ensure that all previous bookmarks, links will point correctly to the new location.

4. And finally, the web.config file:

[code:xml]
<?xml version="1.0"?>
<configuration>
    <system.web>
    <customErrors mode="On"  defaultRedirect="~/error.aspx" >
      <error statusCode="404" redirect="~/error.aspx" />
    </customErrors>
        <compilation debug="true"/></system.web>
</configuration>
[/code]

5. Go to your DNS server settings and configure it as follows:

image

And, that's it. Next time crawlers try to index your old domain they will be politely asked to look at the new site instead.

UPDATE: While it's not visible in the image above, the Address field in the Advanced DNS Settings point to http://<new domain>/<redirect folder>/Default.aspx.

 

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading



About Me

Sameera Perera

Sameera Perera

Log in

RecentComments

Comment RSS

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

Archive

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

All forms of source code published on Codoxide.com are distributed under the Apache License, Version 2.0 unless otherwise stated.
The rest of the content are published under a Creative Commons Attribution 3.0 License.
Creative Commons License

CodoxideTM

Copyright © 2008  codoxide.com. All rights reserved. Designed by Sameera Perera