Redirection from non-www to www on ALB

0

I'm trying to add redirection from non-www to www for current domain on Route 53 that is mapped to ALB as below http://somedomain.sg -> https://www.somedomain.sg

I have added rule on http 80 listener to check if host header is somedomain.sg, redirect to HTTPS://www.#{host}:443/#{path}?#{query}, else if not matched, redirect to HTTPS://#{host}:443/#{path}?#{query}. I have another 443 listener on ALB which is also currently forwarding to target group of attached instances.

I'm unable to get the redirection on broswer, even though both non-www and www domains on Route 53 are mapped to same ALB and ACM certificate on ALB supports both www and non-www domains. Testing with curl on domain somedomain.sg also shows 301 redirect to www.somedomain.sg

Am I missing out on something that is affecting the redirect?

Ryan88
asked a year ago971 views
1 Answer
0
Accepted Answer

The rule for no match is "HTTPS://#{host}:443/#{path}? #{query}" instead of "HTTPS://www.#{host}:443/#{path}? #{query}" instead of "HTTPS://www.#{host}:443/#{path}?
I also think it is enough to create a CNAME record in Route 53 as follows.

record-name: somedomain.sg
type: cname
value: www.somedomain.sg
profile picture
EXPERT
answered a year 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