skip to Main Content

I have a web platform that was build originally on a .co.uk domain. The platform is hosted on nginx ec2 instance. I have now acquired the .com domain for my site and what to fully move over to that domain.

I have essentially replicated my current instance and pointed the .com at the new instance so both work fine in parallel at the moment.

However my Google search adds is all set up with the .co.uk domain and I need to change that using googles domain change tool. They say I should add 301 redirected to the new domain however I am struggling to fine any information on how to do this on AWS from 1 domain/ instance to another.

So I am wondering how I can do a 301 redirect from the old home page to the new domain? Is it possible to do via route 53?

I am wondering if it as simple as just this:

<?php
header("Location: https://www.newdomain.com/", true, 301);
exit();
?>

Thanks

2

Answers


  1. So I am wondering how I can do a 301 redirect from the old home page
    to the new domain? Is it possible to do via route 53?

    No, Route53 just handles domain name resolution. Route53 doesn’t handle HTTP requests/responses. A 301 is a specific type of HTTP response.

    I am wondering if it as simple as just this:

    <?php
    header("Location: https://www.newdomain.com/", true, 301);
    exit();
    ?>
    

    That would tell anyone requesting the old domain, on any page, that the new page URL is https://www.newdomain.com/. It drops the path info from the request, which is almost certainly not what you want, and definitely not what Google is telling you to do.

    I would recommend adding an Nginx configuration to handle requests to the old domain:

    server {
       listen 80;
       server_name olddomain.co.uk;
       return 301 $scheme://www.newdomain.com$request_uri;
    }
    

    This will include the path info in the redirect.

    Login or Signup to reply.
  2. you have to change your nginx configuration a bit to redirect.

    open the .conf file present in your .co.uk site, at the server{ } block,

    add this :

    server {
       listen 80;
       server_name domain.co.uk;
       return 301 $scheme://www.domain.com$request_uri;
    }
    

    This will forward all the incoming requests to www.domain.com so that your all requests will be forwarded with only the change of .co.uk to .com

    Hope this helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search