Wednesday, July 10, 2019

AWS - redirecting domain to url using a 302 redirect (without running a server)

I wanted to make a domain name (heckingoodboys.com) redirect to a multisubreddit for dog pictures, but I didn't want to run a web server for it.

Here's what I did:
  1. Purchase the domain using Route53.
  2. Create two public s3 buckets (www.heckingoodboys.com and heckingoodboys.com)
  3. Enable "Static website hosting" on www.heckingoodboys.com and redirect to heckingoodboys.com.
  4. Enable "Static website hosting" on heckingoodboys.com, select "use this bucket to host this website", and use routing rules similar to this:
    <RoutingRules>
      <RoutingRule>
        <Redirect>
          <Protocol>https</Protocol>
          <HostName>www.reddit.com</HostName>
          <HttpRedirectCode>302</HttpRedirectCode>
          <ReplaceKeyPrefixWith>user/heckingoodboys/m/heckingoodboys/</ReplaceKeyPrefixWith>
        </Redirect>
      </RoutingRule>
    </RoutingRules>
  5. Back to Route53 - Create an A record for both www.heckingoodboys.com and heckingoodboys.com using the alias to their respective buckets. (this will be the first option in autocomplete)
For more details: https://medium.com/@P_Lessing/single-page-apps-on-aws-part-1-hosting-a-website-on-s3-3c9871f126

Why not just use a CNAME from www.heckingoodboys.com to heckingoodboys.com? AWS says they don't charge for aliases, but they do charge for CNAMEs. So, I used an alias to a bucket instead.

4 comments:

  1. I am not really excellent with English but I line up this really easygoing to understand . webflow development agency

    ReplyDelete
  2. Some really wondrous work on behalf of the owner of this site, perfectly great subject material . webflow designers

    ReplyDelete
  3. How is it that just anyone can publish a blog and get as popular as this? Its not like youve said something incredibly impressive –more like youve painted a quite picture above an issue that you know nothing about! I dont want to sound mean, right here. But do you definitely think that you can get away with adding some quite pictures and not really say anything? user experience design

    ReplyDelete
  4. I’m really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a great blog like this one these days.. top front end developers

    ReplyDelete