Issue
I have a a word press website running on an EC2 instance with an application load balancer in front of it.
I also have a certificate from AWS certificate manager for "example.com". This certificate is attached to the ALB "HTTPS" listener.
I also have two route 53 records, one alias to the ALB and another alias to redirect "www" traffic:
- example.com. A ALIAS dualstack.[id].us-east-1.elb.amazonaws.com.
- www.example.com. A ALIAS example.com.
My issue is when trying to access the website, everything is fine except when path parameters are provided, in that case I get the "Your connection is not private" browser error. See example warning here: https://prnt.sc/opip7d
- example.com (Everything is fine, page is loaded properly)
- www.exemple.com (Everything is fine, I get redirected to exemple.com and page loads)
- www.exemple.com/test (NOT fine, I get the "Your connection is not private" warning)
Can anyone shine light on why this would be happening? Shouldn't route53 automatically redirect any traffic regardless?
Solution
You can use listeners rules of AWS ALB to redirect:
HTTP 80: default action
IF Requests otherwise not routed THEN Redirect to HTTPS://#{host}:443/#{path}?#{query}
Status code:HTTP_301
HTTPS:443
IF Host is www.example.com THEN Redirect to HTTPS://example.com:443/#{path}?#{query}
Status code:HTTP_301
Answered By - Vlad