amazon-web-serviceshttpsamazon-route53forwarding

How to forward http request to https in Amazon Route53?


I have a subdomain in Amazon Route53. Let's say secure.example.com

If requests come like https://secure.example.com it is ok but I would like to force http requests to come through https. When user types http://secure.example.com it needs to be forwarded to https://secure.example.com.

Is there a domain level redirecting/forwarding requests coming through http to https in Amazon Route53?


Solution

  • No, there is no way to do this -- because it's not a DNS function to force any particular protocol, or to push values from one protocol to another. You can do this easily enough at the web server level, either in Apache, or IIS, or NGINX.

    In any of those cases, the A or CNAME value pointing a specific record to a specific address (whether an IP or another host name) is the same, it's just going to connect via port 80 or port 443.

    In Apache, you can simply use a rewrite (enable mod_rewrite first):

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://www.host.com/$1 [R]