canonicalization problems

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

asp.net

I have some canonicalization problems with my site. I've just googled my
site using the oprator site and inurl:
site:mydomain.com -inurl:www
Which resulted in a list of links to my site which don't contain the www
link.

In Google Webmaster Tools I've specified preferred domain to be
www.mydomain.com, but I did this about yesterday. Do not think that change
have made any effect on the SERP yet.

In my Global.asax file I have this method:
void Application_BeginRequest(object sender, EventArgs e)
{
string requestedDomain =
HttpContext.Current.Request.Url.ToString().ToLower();

if (requestedDomain.IndexOf("http://domain.com") > 0)
{
requestedDomain = requestedDomain.Replace("http://domain.com",
"http://www.domain.com");
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", requestedDomain);
Response.End();
}
}

In the SERP I mentioned above (site:mydomain.com -inurl:www), if I click on
one of the links (this is links which do not contain www), then I'm taken to
my domain without www. So I suppose the Application_BeginRequest method has
something wrong or there are some other issues I haven't taken care of yet.

any suggestions?
 
hi

asp.net

I have some canonicalization problems with my site. I've just googled my
site using the oprator site and inurl:
site:mydomain.com -inurl:www
Which resulted in a list of links to my site which don't contain the www
link.

In Google Webmaster Tools I've specified preferred domain to bewww.mydomain.com, but I did this about yesterday. Do not think that change
have made any effect on the SERP yet.

In my Global.asax file I have this method:
void Application_BeginRequest(object sender, EventArgs e)
{
    string requestedDomain =
HttpContext.Current.Request.Url.ToString().ToLower();

    if (requestedDomain.IndexOf("http://domain.com") > 0)
    {
        requestedDomain = requestedDomain.Replace("http://domain.com",
"http://www.domain.com");
        Response.Clear();
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", requestedDomain);
        Response.End();
    }

}

In the SERP I mentioned above (site:mydomain.com -inurl:www), if I click on
one of the links (this is links which do not contain www), then I'm takento
my domain without www. So I suppose the Application_BeginRequest method has
something wrong or there are some other issues I haven't taken care of yet.

any suggestions?

this

if (requestedDomain.IndexOf("http://domain.com") > 0)

is wrong because it has to be equal to 0
 
Back
Top