Heroku redirect from example.com to www.example.com retaining HTTPS using AWS Heroku redirect from example.com to www.example.com retaining HTTPS using AWS heroku heroku

Heroku redirect from example.com to www.example.com retaining HTTPS using AWS


I discovered this guide on the Heroku website:Configuring Amazon Route 53 DNS for Your Heroku App

The outline of the solution is to create an S3 bucket as a static website host that simply redirects to your Route53 hosted zone. Here are the basic steps:

  1. Create a new hosted zone on your Route 53 Management Console with your domain (example.com)
  2. Create a CNAME entry for www.example.com with the value set as your heroku custom domain (www.example.com.herokudns.com)
  3. Create an S3 Bucket with the same name as your domain (example.com), and set it as a static website host
  4. In the settings for static website hosting set this to "Redirect Requests" and set the target as www.example.com and the protocol to httpsSettings for s3 bucket static website hosting
  5. Return to Route 53 and add an A Level Alias with the target as your newly created bucket
  6. Finally point your DN Providers Name servers at your new Route 53 hosted zone (you can get the list of name servers from the sidepanel in your management console)

And that's it! After the TTL expires on your Name Servers your site should be up and running and both example.com and www.example.com