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?
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.