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
preguntada hace 2 años1064 visualizaciones
1 Respuesta
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
EXPERTO
Kallu
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas