Search code examples
amazon-web-servicessubdomainamazon-route53

Redirecting a subdomain to another subdomain in the same hosted zone in AWS


Let's say I have B.example.com. B is dead, meaning when I try to go to that subdomain, I get 404. I want to redirect all requests from B.example.com to A.example.com, which is a fully working subdomain. This is all hosted on AWS.

I tried the following:

-created S3 bucket called B.example.com, enabled public access

-made it a static website hosting bucket, with Redirect Requests to A.example.comm, protocol https

-created a new record under example.com domain called B

-chose A type, IPv4, simple routing policy

-enabled Alias, picked my s3 bucket as the endpoint, and saved it

-tried going to B.example.com, it just times out now

I feel like there is an easier way to go about this. This was provided by ChatGPT. Tried it, didn't work. Help welcome, thanks.


Solution

  • Look at your DNS, can you just update your A subdomain to point to your B subdomain and then configure the application on B to perform the redirect?

    If not you probably need to use CloudFront & S3 static sites(updating your DNS to cloudfrount + setup a certificate in ACM) if your apps are using HTTPS as S3 static sites do not support HTTP. See https://repost.aws/knowledge-center/cloudfront-redirect-domain