locked
Whole site 301 to new domain RRS feed

  • Question

  • User1184460004 posted

    Hello,

    I am moving my site to a new domain!

    I don't want to lose our Search rankings and seek your advice on the best way to do it. I have searched the forums and find posts based on domain to domain and php to aspx but nothing regarding a whole site move to a new doamin.

    I have copied all files to a new domain and want to 301 permanent rediret to the same page on a new domain.

    I have standard aspx pages and dynamic pages also based on product pages such as aspx?category=categoryname and i have a forum that has many different dynamic url's for example ?userID=123456 and ?postID=this is the post name.

    Anyone help with some ideas please.

    I am on a shared server.

    Many thanks

    JIM

    Wednesday, April 9, 2014 2:52 PM

Answers

All replies

  • User-760709272 posted

    In the global.asax of the old domain

    void Application_BeginRequest(object sender, EventArgs e)
    {
        string url = Request.Url.OriginalString;
        if (url.Contains("//www.olddomain.com/"))
        {
            Response.RedirectPermanent(Request.Url.OriginalString.Replace("//www.olddomain.com/", "//www.newdomain.com/"));
        }
    }

    You could do with improving it, dealing with case issues etc but that is the gist.

    Wednesday, April 9, 2014 4:26 PM
  • User1184460004 posted

    Thank you for your reply, so this is a single entry and it will serve the whole site without loseing Search engine rankings?

    Many thanks

    JIM

    Thursday, April 10, 2014 4:33 AM
  • User-760709272 posted

    Give it a go to see how it works, but it should redirect any request from old to new just by replacing the domain.

    Thursday, April 10, 2014 4:44 AM
  • User-1404016747 posted

    You can do it in your Web.config by adding a rewrite rule like so.
     
    This rule will also redirect requests to http://olddomain.com or http://www.olddomain.com and redirect them to http://www.newdomain.com while retaining the portion of the URL after the forward. For example http://olddomain.com/page.aspx?userID=123456 would redirect to http://www.newdomain.com/page.aspx?userID=123456 as a 301 redirect

    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Redirect *olddomain.com to www.newdomain.com" StopProcessing="true">
              <match Url=".*" />
              <conditions>
                <add Input="{HTTP_HOST}" Pattern="^olddomain.com$" />
              </conditions>
              <action Type="Redirect" Url="http://www.newdomain.com/{R:0}" RedirectType="Permanent" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration> 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 10, 2014 5:22 AM
  • User1184460004 posted

    Thank you guys - i really appreciate your time.

    Does this also work for www.domain/folderName/page.aspx or www.domain/folderName/page.aspx?ID=abcde

    Thursday, April 10, 2014 12:43 PM
  • User-1404016747 posted

    The rewrite will.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 10, 2014 4:27 PM