How to redirect S3 hosted static site from Domain A to Domain B in AWS Cloudfront setup?











up vote
-1
down vote

favorite












My problem



I'm trying to 301 redirect myS3 hosted domain-a.com to domain-b.com in my SSL-secured AWS Cloudfront setup. I cannot figure out how to achieve this. Instead both domains now serve the Cloudfront/S3 Bucket content.



My use case



Before switching to Cloudfront I used to handle redirects with S3's static website hosting options by redirecting the secondary domain bucket to the primary domain bucket.



In order to secure my S3-hosted static site with SSL certificates I made the switch to Cloudfront.



SSL certificates work fine, but because now both domains point to the cloudfront distribution (see screenshots below) I can access the same content on both domains. This does not only lead to duplicate content but also confuses users and is not really the best UX.



Route 53 and Cloudfront config for both domains




  • Route 53 points to a single Cloudfront distribution for both domain-a.com and domain-b.com

  • Cloudfront points to the domain-b.com S3 bucket


domain-a.com Route 53 configurationdomain-b.com Route 53 configurationCloudfront configuration



How can I redirect domain-a.com to domain-b.com so as to only have one primary domain which my users see and use? Can this be achieved through Route 53 DNS settings or do I have to edit my Cloudfront configuration?










share|improve this question


























    up vote
    -1
    down vote

    favorite












    My problem



    I'm trying to 301 redirect myS3 hosted domain-a.com to domain-b.com in my SSL-secured AWS Cloudfront setup. I cannot figure out how to achieve this. Instead both domains now serve the Cloudfront/S3 Bucket content.



    My use case



    Before switching to Cloudfront I used to handle redirects with S3's static website hosting options by redirecting the secondary domain bucket to the primary domain bucket.



    In order to secure my S3-hosted static site with SSL certificates I made the switch to Cloudfront.



    SSL certificates work fine, but because now both domains point to the cloudfront distribution (see screenshots below) I can access the same content on both domains. This does not only lead to duplicate content but also confuses users and is not really the best UX.



    Route 53 and Cloudfront config for both domains




    • Route 53 points to a single Cloudfront distribution for both domain-a.com and domain-b.com

    • Cloudfront points to the domain-b.com S3 bucket


    domain-a.com Route 53 configurationdomain-b.com Route 53 configurationCloudfront configuration



    How can I redirect domain-a.com to domain-b.com so as to only have one primary domain which my users see and use? Can this be achieved through Route 53 DNS settings or do I have to edit my Cloudfront configuration?










    share|improve this question
























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      My problem



      I'm trying to 301 redirect myS3 hosted domain-a.com to domain-b.com in my SSL-secured AWS Cloudfront setup. I cannot figure out how to achieve this. Instead both domains now serve the Cloudfront/S3 Bucket content.



      My use case



      Before switching to Cloudfront I used to handle redirects with S3's static website hosting options by redirecting the secondary domain bucket to the primary domain bucket.



      In order to secure my S3-hosted static site with SSL certificates I made the switch to Cloudfront.



      SSL certificates work fine, but because now both domains point to the cloudfront distribution (see screenshots below) I can access the same content on both domains. This does not only lead to duplicate content but also confuses users and is not really the best UX.



      Route 53 and Cloudfront config for both domains




      • Route 53 points to a single Cloudfront distribution for both domain-a.com and domain-b.com

      • Cloudfront points to the domain-b.com S3 bucket


      domain-a.com Route 53 configurationdomain-b.com Route 53 configurationCloudfront configuration



      How can I redirect domain-a.com to domain-b.com so as to only have one primary domain which my users see and use? Can this be achieved through Route 53 DNS settings or do I have to edit my Cloudfront configuration?










      share|improve this question













      My problem



      I'm trying to 301 redirect myS3 hosted domain-a.com to domain-b.com in my SSL-secured AWS Cloudfront setup. I cannot figure out how to achieve this. Instead both domains now serve the Cloudfront/S3 Bucket content.



      My use case



      Before switching to Cloudfront I used to handle redirects with S3's static website hosting options by redirecting the secondary domain bucket to the primary domain bucket.



      In order to secure my S3-hosted static site with SSL certificates I made the switch to Cloudfront.



      SSL certificates work fine, but because now both domains point to the cloudfront distribution (see screenshots below) I can access the same content on both domains. This does not only lead to duplicate content but also confuses users and is not really the best UX.



      Route 53 and Cloudfront config for both domains




      • Route 53 points to a single Cloudfront distribution for both domain-a.com and domain-b.com

      • Cloudfront points to the domain-b.com S3 bucket


      domain-a.com Route 53 configurationdomain-b.com Route 53 configurationCloudfront configuration



      How can I redirect domain-a.com to domain-b.com so as to only have one primary domain which my users see and use? Can this be achieved through Route 53 DNS settings or do I have to edit my Cloudfront configuration?







      amazon-web-services amazon-s3 dns amazon-cloudfront amazon-route53






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 12 hours ago









      wntrmt

      617




      617
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Create a separate bucket for domain-a.com, configure that in your CloudFront and apply the redirect rules to point it to domain-b.com.



          Check the picture below on how to set the redirect.



          Redirect all requests to domain-b.com



          Hope it helps.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416119%2fhow-to-redirect-s3-hosted-static-site-from-domain-a-to-domain-b-in-aws-cloudfron%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Create a separate bucket for domain-a.com, configure that in your CloudFront and apply the redirect rules to point it to domain-b.com.



            Check the picture below on how to set the redirect.



            Redirect all requests to domain-b.com



            Hope it helps.






            share|improve this answer

























              up vote
              0
              down vote













              Create a separate bucket for domain-a.com, configure that in your CloudFront and apply the redirect rules to point it to domain-b.com.



              Check the picture below on how to set the redirect.



              Redirect all requests to domain-b.com



              Hope it helps.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Create a separate bucket for domain-a.com, configure that in your CloudFront and apply the redirect rules to point it to domain-b.com.



                Check the picture below on how to set the redirect.



                Redirect all requests to domain-b.com



                Hope it helps.






                share|improve this answer












                Create a separate bucket for domain-a.com, configure that in your CloudFront and apply the redirect rules to point it to domain-b.com.



                Check the picture below on how to set the redirect.



                Redirect all requests to domain-b.com



                Hope it helps.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 11 hours ago









                Kannaiyan

                5,67411942




                5,67411942






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416119%2fhow-to-redirect-s3-hosted-static-site-from-domain-a-to-domain-b-in-aws-cloudfron%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    What visual should I use to simply compare current year value vs last year in Power BI desktop

                    Alexandru Averescu

                    Trompette piccolo