# Set up WWW Domain Redirect

**URL:** <https://discourse.sst.dev/t/set-up-www-domain-redirect/142>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142 "2018-05-09T20:09:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/1 "2018-05-09T20:09:41Z")

</div>

_From @jayair on Mon Apr 10 2017 01:09:47 GMT+0000 (UTC)_  
  
Link to chapter - [http://serverless-stack.com/chapters/setup-www-domain-redirect.html](http://serverless-stack.com/chapters/setup-www-domain-redirect.html)  
  
_Copied from original issue: [https://github.com/AnomalyInnovations/serverless-stack-com/issues/66](https://github.com/AnomalyInnovations/serverless-stack-com/issues/66)_

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/2 "2018-05-09T20:09:42Z")

</div>

_From @pjamieson on Mon Jul 03 2017 20:01:42 GMT+0000 (UTC)_  
  
Rather than create a second CloudFront Distribution, why not just add the alias www.[my-domain].com to the Route53 Record Sets for [my-domain]–pointing to the first distribution–then add www.[my-domain].com to that first distribution’s Alternate Domain Names? That seems to work fine. Am I missing something?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/3 "2018-05-09T20:09:43Z")

</div>

_From @jayair on Mon Jul 03 2017 20:33:01 GMT+0000 (UTC)_  
  
@pjamieson The reason we set up a redirect on our alternate domain is for SEO purposes. Not necessarily for ranking but because we don’t want two versions of our domain active. By re-directing one (the www or apex domain) to the other we are telling the search engines to use one as opposed to both. I hope that makes sense.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/4 "2018-05-09T20:09:43Z")

</div>

_From @pjamieson on Mon Jul 03 2017 20:45:12 GMT+0000 (UTC)_  
  
Thanks, @jayair. That makes sense.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/5 "2018-05-09T20:09:43Z")

</div>

_From @jayair on Mon Jul 03 2017 21:12:26 GMT+0000 (UTC)_  
  
@pjamieson Just added a small note to the chapter [https://github.com/AnomalyInnovations/serverless-stack-com/commit/9b67ea34af928bf38025b882b2e6181a6df082cf](https://github.com/AnomalyInnovations/serverless-stack-com/commit/9b67ea34af928bf38025b882b2e6181a6df082cf).

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/6 "2018-05-09T20:09:43Z")

</div>

_From @x11joe on Sat Nov 11 2017 12:02:09 GMT+0000 (UTC)_  
  
I’m getting the following error on this step, `com.amazonaws.services.cloudfront.model.CNAMEAlreadyExistsException: One or more of the CNAMEs you provided are already associated with a different resource. (Service: AmazonCloudFront; Status Code: 409; Error Code: CNAMEAlreadyExists; Request ID: e21a6bde-c6d7-11e7-9415-837f645450a5)`, any ideas?

My bucket name is definitely different, so not sure…

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/7 "2018-05-09T20:09:44Z")

</div>

_From @jayair on Sat Nov 11 2017 19:37:26 GMT+0000 (UTC)_  
  
@x11joe This usually has to do with a CloudFront distribution having a CNAME already listed as the one you are trying to add. On which screen are you seeing this?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/8 "2018-05-09T20:09:44Z")

</div>

_From @x11joe on Sat Nov 11 2017 20:10:14 GMT+0000 (UTC)_  
  
I am seeing this on the part where you say … `Scroll down to the Alternate Domain Names (CNAMEs) and use the www version of our domain name here.`

It shows up at the bottom, I’ll try and get a screenshot.

…

Well… this is going to sound stupid but I tried just now and its working all the sudden?? Maybe this happened because I was doing test with the domain name prior on another serverless tutorial and it takes like 24 hours for it to remove it’s self? Not sure. Maybe this post will help someone.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/9 "2018-05-09T20:09:44Z")

</div>

_From @jayair on Sat Nov 11 2017 20:14:39 GMT+0000 (UTC)_  
  
@x11joe Yeah this can happen. Both the domain setting part and the CloudFront distributions take some time to apply their changes.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:09pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/10 "2018-05-09T20:09:44Z")

</div>

_From @johnnybigert on Mon Nov 27 2017 15:09:01 GMT+0000 (UTC)_  
  
I just registered a domain (let’s call it “[mysite.com](http://mysite.com)”) and it shows the Notes app correctly. The s3 url and the cloudflare distribution url also show the Notes app. When trying to get the redirect from [www.mysite.com](http://www.mysite.com) to work, I get the following behavior:

[http://www-xxx-notes-app-client.s3-website-us-east-1.amazonaws.com](http://www-xxx-notes-app-client.s3-website-us-east-1.amazonaws.com) redirects correctly to [mysite.com](http://mysite.com). However, [http://www.mysite.com/](http://www.mysite.com/) and [xxx.cloudfront.net](http://xxx.cloudfront.net) (which is the www cloudfront distribution url) both give

```auto
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
  <Code>AccessDenied</Code>
  <Message>Access Denied</Message>
  <RequestId>xxx</RequestId>
  <HostId>xxx</HostId>
</Error>

```

I have looked through the settings of the s3 redirect bucket, the www cloudfront distribution and the hosted zone record sets and they seem correct. Any ideas what to do?

---

<div class="post-metadata">

**Author:** ![rjison9000](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@rjison9000](https://discourse.sst.dev/u/rjison9000)\
**Post date:** [September 23, 2018, 6:58pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/11 "2018-09-23T18:58:44Z")

</div>

I’ve just run into this myself and was wondering if you resolved it.

Thanks

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [October 1, 2018, 6:46pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/12 "2018-10-01T18:46:47Z")

</div>

Which issue are you referring to?

---

<div class="post-metadata">

**Author:** ![s3341458](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@s3341458](https://discourse.sst.dev/u/s3341458)\
**Post date:** [May 30, 2019, 1:48pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/13 "2019-05-30T13:48:36Z")

</div>

I have exactly the same problem, did you find the solution?  
many thanks.

---

<div class="post-metadata">

**Author:** ![s3341458](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@s3341458](https://discourse.sst.dev/u/s3341458)\
**Post date:** [May 30, 2019, 1:50pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/14 "2019-05-30T13:50:23Z")

</div>

I think @rjison9000 refers to the ‘Access Denied’ problem.

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [June 12, 2019, 11:58pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/15 "2019-06-12T23:58:54Z")

</div>

Whats the issue you are having?

---

<div class="post-metadata">

**Author:** ![s3341458](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@s3341458](https://discourse.sst.dev/u/s3341458)\
**Post date:** [June 13, 2019, 12:04pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/16 "2019-06-13T12:04:54Z")

</div>

I have already solved my problem with this [https://github.com/AnomalyInnovations/serverless-stack-com/issues/66#issuecomment-347220022](https://github.com/AnomalyInnovations/serverless-stack-com/issues/66#issuecomment-347220022)

thank you very much

---

<div class="post-metadata">

**Author:** ![shadow](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shadow](https://discourse.sst.dev/u/shadow)\
**Post date:** [September 17, 2019, 7:03pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/17 "2019-09-17T19:03:16Z")

</div>

if its only in effect a redirect, we could avoid route 53 and cloudfront and save ourselves some money a month by doing it from the registrars website, no?

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [September 28, 2019, 6:24pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/18 "2019-09-28T18:24:43Z")

</div>

You could but the cost for this extremely small.

---

<div class="post-metadata">

**Author:** ![groffcole](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@groffcole](https://discourse.sst.dev/u/groffcole)\
**Post date:** [April 24, 2020, 3:19am UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/19 "2020-04-24T03:19:59Z")

</div>

Why create a CloudFront distribution for the www redirect? Is it necessary?

Or could you have the alias record point directly to the S3 bucket?

Thanks.

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [April 25, 2020, 5:16pm UTC](https://discourse.sst.dev/t/set-up-www-domain-redirect/142/20 "2020-04-25T17:16:24Z")

</div>

I think you could. We used the CF for the sake of completeness.
