Lukas Z's Blog

How to Redirect HTTP and HTTPS Requests Using Namecheap and AWS

This is a mini writeup for a very specific case.

Let’s say we have a domain name, And for some reason we want to redirect all traffic to And the following things also apply:

  • is registered at a hoster like Namecheap.
  • does not belong ot us at all.
  • we want to redirect and
  • we are already using AWS.

(Told you it was specific..)

Then we can do this:

  1. Set up an empty S3 bucket at AWS and make it public.
  2. In the properties of the bucket use the Static Website Hosting feature in Properties and define a redirect to Take note of the Endpoint value in the Static Website Hosting box.
  3. Because we support HTTPS use ACM to create a certificate that matches and (or *
  4. Create a Cloudfront distribution that uses that bucket’s Endpoint as origin and is valid for the domains and Use the certificate from the step before.
  5. Configure ALIAS records at Namecheap for www and @ pointing to the domain name of our Cloudfront distribution.


Now every request to will result in a DNS query that returns the ALIAS entry (though I believe ALIAS is not a standard key but a technicality provided by Namecheap and others to circumvent the restriction of CNAME, which one would normally use, but which cannot be used with @ unless you are ok with masking your MX and other subdomain records).

So our request will be actually fired against the IP address at Cloudfront but the client still expects a valid SSL certificate for Cloudfront provides that (created in step 3) and we can finally get to the (cached) bucket, which only does one thing: 301 redirect the client to

P.S.: You can follow me on Twitter.