Amplify redirect www to apex

0

I'm new to AWS in general, and can't seem to figure out how to redirect my www subdomain to my root domain. Both my apex domain and www successfully show the website. But I want to redirect www to apex so when users type www.my.tld they end up in my.ltd

The domain is registered with Google, and set to use the AWS name servers of my hosted zone on Route 53.

The records for my hosted zone are as following:

my.tld		A	abcdefg99.cloudfront.net.
my.tld		NS	[nameservers]
my.tld		SOA	....
www.my.tld	CNAME	abcdefg99.cloudfront.net.

In the Rewrites and redirects section of Amplify I have:

/<*>			https://abc.cloudfront.net/<*>	200 (Rewrite)
/<*>			/index.html			404 (Rewrite)
https://www.my.tld	https://my.tld			302 (Redirect - Temporary) RIGHT???

I would expect the above to redirect my www to the apex. But no luck so far.

I also tried changing www.my.tld CNAME abcdefg99.cloudfront.net. to www.my.tld CNAME my.tld. but that didn't even resolve the DNS.

Any thoughts on this? Is this even possible with Amplify? I also stumbled upon this but couldn't apply the solution to my issue.

1 Answer
0

I'm hosting by blog carriagereturn.nl on Amplify and there are differences to your R53 and rewrite config; I have permanent redirect (301) as the first rule.

www.my.tld  https://my.tld 301
/<*>        /index.html    404

And Route53 for www -address is CNAME to applifyapp, not cloudfront.

www.my.tld	CNAME	*.abcdefg99.amplifyapp.com 

I hope this helps you in getting www->apex rewriting to work.

profile picture
EXPERT
Kallu
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions