published: 6th of May 2020
I previously hosted my domains with GoDaddy. In their service it was pretty trivial to redirect a URL from one domain to another. I own the domain bradleysearle.com and I redirect it to https://codingpackets.com/. The process to do this is not as simple with AWS so in this post I will show you how to accomplish this using the Route 53 and S3 services.
Firstly you must create an S3 bucket. Browse to:
Enter the bucket name and set the bucket region and press create bucket.
To modify the bucket to act as a Static web hosting bucket browse to:
Select the option the Redirect requests, enter the URL in the Target bucket or domain field. Protocol, Then press save.
That's it for the S3 component. Now lets move onto the Route 53 component.
Create a hosted zone for your domain. Browse to:
Enter the Domain Name, keep the type as Public Hosted Zone the press Create.
Browse to the newly created Hosted Zone
Create an Alias record by pressing the Create Record Set button.
Select the Alias: Yes button and select the previously created S3 <bucket-name>. Then press Create.
That's it for the Route 53 component.
The trusty curl CLI tool can be used to test the redirect is working.
curl -sD - -o /dev/null bradleysearle.com
# output
HTTP/1.1 301 Moved Permanently
x-amz-id-2: bg3q2exWKIyi4+qzEH+30WwBlIrpxDoZD37k6Q7BMn3+qpBMTamUBYLCw++MY6eLzFEB5ju6cJM=
x-amz-request-id: 5F858D21794D6A70
Date: Tue, 05 May 2020 21:25:00 GMT
Location: https://codingpackets.com//
Content-Length: 0
Server: AmazonS3
You can see from the output we get a HTTP 301 redirect for bradleysearle.com that points to https://codingpackets.com/. SUCCESS!!!!
In this post I showed you how to setup a URL redirect using the AWS Route 53 and S3 services. Its not as simple as some other service providers but at the same time there is not a lot to it.
https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
https://aws.amazon.com/premiumsupport/knowledge-center/redirect-domain-route-53/
https://stackoverflow.com/questions/3252851/how-to-display-request-headers-with-command-line-curl