Redirect subdomain URL to URL subdirectory on Amazon AWS

前端 未结 1 453
陌清茗
陌清茗 2020-12-30 07:22

We\'ve created a subdomain via Route 53 on AWS that points to an external server. We now want to redirect that traffic back to the main domain, but to a subdirectory.

<
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 07:49

    If I understand correctly, you want ALL requests to shop.mydomain.com to redirect to mydomain.com/shop.

    In that case I recommend using S3's "Redirection Rules".

    Create a bucket in S3 called shop.mydomain.com. Open the bucket properties and set the bucket to "Enable Website Hosting". Then select the "Edit Redirection Rules" option.

    AWS Console Edit Redirection Rules Screenshot

    We now need to define a redirection rule that matches every request, and redirects it to mydomain.com/shop

    
      
        
          https
          mydomain.com
          shop/
          301
        
      
    
    

    This rule will match every request and redirect it.

    For more info on routing rules, check out the official docs: http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax

    Now, you need to configure shop.mydomain.com in Amazon Route 53 as an ALIAS record pointing at the bucket you just created, shop.mydomain.com.

    That's it - Enjoy!

    0 讨论(0)
提交回复
热议问题