Home > database >  Redirecting non-WWW to WWW in AWS not working
Redirecting non-WWW to WWW in AWS not working

Time:04-06

I tried to set a redirection from a non-WWW domain to a WWW domain. For this thread, my domain is example.com. So I want to redirect example.com to www.example.com. All the resources in this thread are also HTTPS-protocol based.

I understood that I needed to set an S3 bucket for this. So I've created a bucket called example.com. I configured it as a static website hosting with public permissions: enter image description here

I also configured it to redirect to another domain: enter image description here

Then in Route53 I have 2 relevant entries under xxx.com domain:

The first one is to capture the xxx.com domain and forward it to the S3 bucket: enter image description here

The second one is to capture the example.xxx.com domain and forward it to my load balancer (which then forwards it to my ECS cluster..): enter image description here

So it seems for me all configuration is correct. However, I have been waiting for 2 days for the DNS propagation delay. But still: I cannot access via: https://example.com. I can access the S3 bucket public url (Bucket website endpoint) - which is also set in the route53 as an alias for non-WWW domain. And I can access https://www.example.com. Only non-WWW domains won't work: I get timeout..

Any advice?


I've also doing the same thing using load balancer for this redirection.

I've set the Route53 to forward the "example.com" domain to my load balancer. enter image description here

Then in the load balancer configuration I set: enter image description here

So now when I type: "example.com" I can access my web application, but I get routed to "https://example.com" - and not to WWW.

CodePudding user response:

Why not using your ALB to do his for you? Point both, www and non-www to your ALB and create a rule to check the Host like this one: enter image description here

Please add this rule to port 443, there might be issue.

For Port 80 I redirect directly to the correct host, like www.{host]...

For the rules in 443 I do the redirect explicit like shown in my screenshot.

Most browser add the https protocol by default, so just typing example.com will be requested as example.com instead of some years ago example.com

  • Related