0

I have two domains registered with 1&1 and am using their windows server package. I had both of these domains pointing to the same directory on my server so they show the same content. I am concerned (after reading) that this could cause two issues:

  1. Duplicate content
  2. Individual page ranking

What I actually want is for each page of the .co.uk to point to the equivalent .com page such that all traffic for .co.uk actually goes to the .com equivalent. For example. If I type http://www.hydrostyleuk.co.uk/faq/faq.aspx into my address bar I want it to go to http://www.hydrostyleuk.com/faq/faq.aspx I am pretty sure what I am looking for is a 301 redirect to achieve this but I am not sure how to go about this. I am a C# developer by trade and haven't hosted my own site before so haven't come across this issue before.

I tried to forward my domain as 1&1 describe however this doesn't seem to exhibit the behaviour I want. When checking the redirect via http://www.howto301redirect.com/301-redirect-checker/ I actually have a 302 and the page goes to the root page of my .com domain instead of the relevant sub directory as described above.

I am not sure where to begin to get this working correctly. My biggest focus is on trying to get my SEO correct so the redirect has to work as intended.

As a little further information my site is written in asp.net and hosted on the 1&1 windows server package.

1 Answer 1

0

I have now come up with a solution to this issue. 1&1 windows hosting (the package I am on) does not seem to allow the usual rewrite solution in the web.config which made things difficult but as it turns out not at all impossible. After much head scratching and not looking at things like a C# dev I finally put my C# cap back on and realised the solution. I simply wrote the code below in the codebehind of my master page (as I wanted it to propogate through all pages) and it now performs the redirect correctly as shown on 301-redirect-checker

        protected void Page_Load(object sender, EventArgs e)
        {
        // Permanently 301 Redirect .co.uk to .com
        if (Context.Request.Url.AbsoluteUri.ToUpper().Contains("MYSITE.CO.UK"))
        {
            Context.Response.Status = "301 Moved Permanently";

            Context.Response.AddHeader("Location", "http://www.mysite.com" + Context.Request.Url.AbsolutePath);

            if (Request.Url.AbsolutePath.ToUpper() == "/DEFAULT.ASPX")
            {
                Response.AddHeader("Location", "http://www.mysite.com");
                Context.Response.RedirectPermanent("http://www.mysite.com");
            }
            else
            {
                Context.Response.AddHeader("Location", "http://www.mysite.com" + Context.Request.Url.AbsolutePath);

                Context.Response.RedirectPermanent("http://www.mysite.com" + Context.Request.Url.AbsolutePath);
            }
        }
    }
1
  • Can you please check the link 301-redirect-checker, is it correct? Aug 14, 2014 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.