Reputation: 5344
I have deployed my application on EC2 - ubuntu 18.04 (Apache server). I registered this EC2 with an Application Load Balancer, I want to redirect non-www traffic to https://www.mydomain.co
When I type www.mydomain.co in browser, it redirects to https://www.mydomain.co which is working fine. But when I type without www that is only mydomain.co then it shows "This site can’t be reached".
Following are the rules I defined in ALB -
Can anyone help please?
Upvotes: 1
Views: 7683
Reputation: 335
I am try the config the same setting, on Route53, I have 2 (A) records both pointed to the alb server
domain.com -> ALB DNS Name
www.domain.com -> ALB DNS Name
You have 2 listeners on ALB Port 80 and 443
on port 80, use 301 redirects to All traffic
to HTTPS (Port 443)
on Port 443, points the destination to your desired webserver
Upvotes: 0
Reputation: 238727
This should be done on the domain level, not on the load balancer.
If you use Route53, then you should create a new ALIAS record mydomain.co
which points to the URL of your load balancer. Or a record redirecting mydomain.co
to www.mydomain.co
.
This way both mydomain.co
and www.mydomain.co
will be directed to the ALB.
If you don't use Route53, similar operation should be performed on your domain registrar.
Upvotes: 3