<commit_before>---
layout: post
title: Set up WWW Domain Redirect
date: 2017-02-10 00:00:00
description: Tutorial on how to create a www domain redirect using S3 redirect, CloudFront, and AWS Route 53.
comments_id: 66
---

There's plenty of debate over the www vs non-www domains and while both sides have merit; we'll go over how to set up another domain (in this case the www) and redirect it to our original. If you prefer having the www domain as the default simply swap this step with the last one where we created a bare domain (non-www).

To create a new domain and have it redirect we are going to use the redirection feature that S3 Buckets have. So let's start by creating a new S3 redirect Bucket for this.

### Create S3 Redirect Bucket

Create a new S3 Bucket through the [AWS Console](https://console.aws.amazon.com). The name doesn't really matter but it pick something that helps us distinguish between the two.

![Create S3 Redirect Bucket screenshot]({{ site.url }}/assets/create-s3-redirect-bucket.png)

Next just follow through the steps and leave the defaults intact.

![Use defaults to create S3 redirect bucket screenshot]({{ site.url }}/assets/use-defaults-to-create-bucket.png)

Now go into the **Properties** of the new bucket and click on the **Static website hosting**.

![Select static website hosting screenshot]({{ site.url }}/assets/select-static-website-hosting-2.png)

But unlike last time we are going to select the **Redirect requests** option and fill in the domain we are going to be redirecting towards. This is the domain that we set up in our last chapter.

Also, make sure to copy the **Endpoint** as we'll be needing this later.

![Select redirect requests screenshot]({{ site.url }}/assets/select-redirect-requests.png)

And hit **Save** to make the changes. Next we'll create a CloudFront Distribution to point to this S3 redirect Bucket.

### Create a CloudFront Distribution
<commit_msg>Update setup-www-domain-redirect.md<commit_after>---
layout: post
title: Set up WWW Domain Redirect
date: 2017-02-10 00:00:00
description: Tutorial on how to create a www domain redirect using S3 redirect, CloudFront, and AWS Route 53.
comments_id: 66
---

There's plenty of debate over the www vs non-www domains and while both sides have merit; we'll go over how to set up another domain (in this case the www) and redirect it to our original. The reason we do a redirect is to tell the search engines that we only want one version of our domain to appear in the search results. If you prefer having the www domain as the default simply swap this step with the last one where we created a bare domain (non-www).

To create a new domain and have it redirect we are going to use the redirection feature that S3 Buckets have. So let's start by creating a new S3 redirect Bucket for this.

### Create S3 Redirect Bucket

Create a new S3 Bucket through the [AWS Console](https://console.aws.amazon.com). The name doesn't really matter but it pick something that helps us distinguish between the two.

![Create S3 Redirect Bucket screenshot]({{ site.url }}/assets/create-s3-redirect-bucket.png)

Next just follow through the steps and leave the defaults intact.

![Use defaults to create S3 redirect bucket screenshot]({{ site.url }}/assets/use-defaults-to-create-bucket.png)

Now go into the **Properties** of the new bucket and click on the **Static website hosting**.

![Select static website hosting screenshot]({{ site.url }}/assets/select-static-website-hosting-2.png)

But unlike last time we are going to select the **Redirect requests** option and fill in the domain we are going to be redirecting towards. This is the domain that we set up in our last chapter.

Also, make sure to copy the **Endpoint** as we'll be needing this later.

![Select redirect requests screenshot]({{ site.url }}/assets/select-redirect-requests.png)

And hit **Save** to make the changes. Next we'll create a CloudFront Distribution to point to this S3 redirect Bucket.

### Create a CloudFront Distribution

{'fraction_non_alphanumeric': 0.07527950310559006, 'fraction_numerical': 0.01391304347826087, 'mean_word_length': 4.325396825396825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 13, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '806834', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1035, 'n_words': 600}