301 Redirect - How to verify old domain for Google's Change of Address

Discussion in 'General troubleshooting' started by RajanAM, Jun 25, 2009.

  1. Hi Friends,

    I recently moved to a new primary domain but also have kept the old domain pointing to the same IP Address/web site.

    I also have done 301 redirect.

    I still want some clarifications and would appreciate your feedback.

    1. Which event is the most appropriate place to put your 301 direct script.
    I would assume it is session_start, but in examples on various sites it appears to be in application_beginrequest.

    2. for a succesful "change of address" Google requires that we also verify our old address using the 'verify-v1' meta tag. But when I
    - save to a session variable Session["verifyv1"] the content of verify_v1 corresponding to the old domain,
    - then 301 redirect to the new domain,
    - post to 'verify-v1' in page_load of default.aspx the session variable's value is null??

    I am therefore unable to verify the old domain.

    Any suggestions?

    Thanks.
     
  2. Try using this kb article.

    http://kb.discountasp.net/KB/a369/h...omain-to-a-subdirectory.aspx?KBSearchID=44149

    This kb article is specifically created for subdomains but it should work will full domain names and domain pointers. This script should go at the top of your startup page in the root.

    To make sure you throw the http status code 301 you should able to also add into the code...

    Response.Status="301 Moved Permanently"
     
  3. Thanks for your response.

    The 301 redirect works correctly using the code below in the Application_BeginRequest.

    But what I am unable to do is dynamically change the metatag 'verifyv1' when I access the site using olddomain.

    When I uncomment & use this line the application goes into a loop??
    //Response.Headers.Set("verifyv1", "d6VLTnhcLArSE3Rdth7Q5S8pJp4H7kYui+yuusRspj2==");

    This is the code for the 301 Redirect:

    if (Request.Url.Host.Contains("olddomain.com") || sDNS.IndexOf("www.") < 0)
    {
    Response.StatusCode = 301;
    Response.Status = "301 Moved Permanently";
    //
    sDNS = sDNS.Replace("olddomain.com", "newdomain.com");

    //Response.Headers.Set("verifyv1", "d6VLTnhcLArSE3Rdth7Q5S8pJp4H7kYui+yuusRspj2==");

    //
    if (sDNS.IndexOf("www.") < 0)
    {
    sDNS = sDNS.Insert(sDNS.IndexOf("//") + 2, "www.");
    }
    //
    if (sDNS.ToLower().EndsWith("/default.aspx"))
    {
    sDNS = sDNS.Substring(0, sDNS.IndexOf("/default.aspx"));
    }
    //
    Response.AddHeader("Location", sDNS);
     

Share This Page