Check out a free preview of the full AWS for Front-End Engineers (ft. S3, Cloudfront & Route 53) course:
The "Setting Up a WWW Subdomain" Lesson is part of the full, AWS for Front-End Engineers (ft. S3, Cloudfront & Route 53) course featured in this preview video. Here's what you'd learn in this lesson:

Steve sets up a second S3 bucket for redirecting from the "www" subdomain (e.g., http://www.example.com) to the bare domain (e.g., http://example.com). He also configures the DNS settings in Route 53 to work with the new bucket.

Get Unlimited Access Now

Transcript from the "Setting Up a WWW Subdomain" Lesson

[00:00:00]
>> Steve Kinney: The other issue is if I someone goes to www,
>> Steve Kinney: Can't find the server. All right, one would argue it's 2018, why are you making me do this? I know there is a page that people link to, which is like a manifesto on why you should use www.

[00:00:18] I haven't read it, but I know that it exists. So that I know that having both is probably good. Cool, so let's get that set up. Now,
>> Steve Kinney: One easy way to do an S3, is, if you remember when we saw static web hosting before, there was this other one down here.

[00:00:36] It says redirect requests. That seems interesting. Obviously we don't wanna do it on this bucket cuz it is hosting it. What we can do is, we know that if we are doing static web hosting with S3 that the bucket has to have the same name as the URL, right?

[00:00:54] We also see here that we can redirect requests. So what we're gonna do is we're gonna setup a second bucket, we're gonna name www.superimportantwebsite.com. And we'll have it redirect to this bucket and then we'll just have to update route 53. All right, let's do it together. Cool, so we'll go back to S3, we'll make another one called www.superimportantwebsite.com.

[00:01:26]
>> Steve Kinney: Take all the defaults just like last time. So now we have it. We go into the bucket, go to Properties > Static website hosting. I apparently clicked a link instead of,
>> Steve Kinney: Cool. So here we'll redirect requests, and it's like, okay what is the bucket that you would like to redirect to?

[00:01:48] superimportantwebsite.com,
>> Steve Kinney: Cool. So now, If we have a super important website, but then we also have that one that's in the bucket, right? We haven't set up the DNS for www.superimportantwebsite just yet. But we can see if we take the actual bucket address, put the www there, that it now redirects, right?

[00:02:17] And you can see it changed the URL, it just got rid of that, it actually brought us back to superimportantwebsite.com. So no one's going to type in www.superimportantwebsite.com.s3-website-us-east-1-amazonaws.com, that's not gonna be the mistake people make. They're gonna try to type www.superimportantwebsite. So let's go ahead and we'll go into the Route 53 console.

[00:02:54]
>> Steve Kinney: Look, Route 53, recently visited. We'll go into Registered domains > superimportantwebsite.
>> Steve Kinney: And cool, so we'll go ahead to Go to Record Sets, and this is gonna be exactly like it was last time. We'll create new record. This time we'll type in www, we'll set the alias, and there it is, there's my bucket.

[00:03:29]
>> Steve Kinney: I can hit Create. Again, I could theoretically get really ambitious and immediately go to www.superimportantwebsite.com, and maybe the DNS propagate it. I'm gonna do it, but I've got a, it didn't work last time, it's not gonna work this time.
>> Steve Kinney: But I'm hopeful. superimportantwebsite.com. Yeah, so that DNS needs to propagate.

[00:03:57] But we'll check on it a little bit. We should now have www support as well. All right, great, so we now have effectively somewhat fixed client side routing. We will, as soon as the DNS propagates, have a www domain. We still have a few problems in here, which is we are still over on HTTPS, we still have to do this manually, still hosted in Virginia.

[00:04:28] And our routing is not breaking the app, but it's definitely breaking the social contract, that is what a 404 means, [LAUGH] right? So we still have to solve those issues, but we're getting there.