I created a bucket in s3. Static website hosting, choose Enable. I upload two html file.
page1.html
This is page1
page2.html
This is page2
I added metadata x-amz-website-redirect-location = /page2.html into page1 object in s3 website console.
curl -v the site
$ curl -v https://aws-redirect-test.s3.ap-northeast-1.amazonaws.com/page1.html
* Trying 3.5.154.185...
* TCP_NODELAY set
* Connected to aws-redirect-test.s3.ap-northeast-1.amazonaws.com (3.5.154.185) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=*.s3-ap-northeast-1.amazonaws.com
* start date: Dec 9 00:00:00 2021 GMT
* expire date: Dec 2 23:59:59 2022 GMT
* subjectAltName: host "aws-redirect-test.s3.ap-northeast-1.amazonaws.com" matched cert's "*.s3.ap-northeast-1.amazonaws.com"
* issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
* SSL certificate verify ok.
> GET /page1.html HTTP/1.1
> Host: aws-redirect-test.s3.ap-northeast-1.amazonaws.com
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< x-amz-id-2: jWBm/e0Rdb2BB3R/nFffH8/YS2 f1AgXFHQfT6bUzmMK9tMZDtSNYprUp4Ka6m9xMKookshlWwo=
< x-amz-request-id: T4JG7K11X2FTBCA8
< Date: Thu, 09 Jun 2022 02:15:03 GMT
< Last-Modified: Thu, 09 Jun 2022 02:12:42 GMT
< ETag: "a12ac1ca5226842e56871deaa4d9ef9c"
< x-amz-website-redirect-location: /page2.html
< Accept-Ranges: bytes
< Content-Type: text/html
< Server: AmazonS3
< Content-Length: 14
<
This is page1
* Connection #0 to host aws-redirect-test.s3.ap-northeast-1.amazonaws.com left intact
* Closing connection 0
CodePudding user response:
You are not using the website endpoint. I tested the following url and it works.
http://aws-redirect-test.s3-website-ap-northeast-1.amazonaws.com/page1.html