canonicalization problems

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?
 
G

Guest

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 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?

this

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

is wrong because it has to be equal to 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top