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.

nxr
已提問 2 年前檢視次數 1064 次
1 個回答
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
專家
Kallu
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南