PHPnews.io

Amazon S3/CloudFront redirect www to non-www and HTTP to HTTPS

Written by Simone Carletti / Original link on Aug. 4, 2016

This article assumes you want to redirect a www version of a domain (e.g. www.example.com) to the non-www root domain (e.g. example.com) with HTTPS, and using Amazon S3 static site redirect and CloudFront.

Introduction

Before we start, there are a few important notes to keep in mind:

CloudFront Configuration

To configure the redirect, follow the detailed instructions in this article. In the referenced article, the redirecting host name is the host name that will redirect, whereas the target host name is the target of the redirect.

For example, if you want to redirect http://www.example.com and https://www.example.com to https://example.com, then you will have to follow the steps detailed in the article and:

Instead, if you want to redirect http://example.com and https://example.com to https://www.example.com, then you will have to follow the steps detailed in the article and:

If you should experience some issues, check the common errors section.

sitepoint softwares simonecarletti

« Apache redirect www to non-www and HTTP to HTTPS - Redirecting a domain with HTTPS using Amazon S3 and CloudFront »