简体   繁体   中英

Setting up the dns of amazon sw3 bucket, creating subdomain url router amazon s3

I have a repository bucket on amazon. In this repository I have a page, with only css, js and html, I start the application with the index.html.

The application url is available, and look like this :

example.s3-aws-region.amazonaws.com. 

I want to redirect all subdomain of the url to the url application, for example if I go to the following url I want to redirect to the url of the app :

bucket.example.s3-aws-region.amazonaws.com
subdomain.example.s3-aws-region.amazonaws.com
subdomain_2.example.s3-aws-region.amazonaws.com

(Note that the domain is provided by amazon, not a personal domain)

So, I need to edit the dns and create a CNAME record. I tried creating a host zone, and then I created a CNAME record with the following value *.example.s3-aws-region.amazonaws.com

But it didn't work

How can I do it?

You cannot do this using CNAME entries because you do not own the amazonaws.com domain.

Instead, you can use multiple buckets along with 301 redirects.

  1. Create your main bucket, let's assume it's called example .
  2. Create a second bucket called subdomain.example .
  3. On subdomain.example , configure "Static Website Hosting" to "Redirect all requests to another host name" using example.s3-website-region.amazonaws.com as the target.

Then, in your browser, if you go to subdomain.example.s3-website-region.amazonaws.com , you will be 301 redirected to example.s3-website-region.amazonaws.com .

Note that this is a 301 redirect, it's not a CNAME or an alias. So the redirect will be visible in the browser address bar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM