Cloudfront distribution redirects to wrong domain on 404

Viewed 16

I have two static web sites hosted on S3 as simple HTML pages.

route53 <---> CloudFront <---> S3 bucket (origins)

first.mysite.com <---> d2cjfirst6diey.cloudfront.net <---> mysite-first-bucket.s3-website-us-east-1.amazonaws.com

second.mysite.com <---> dsecondru55iarz.cloudfront.net <---> mysite-second-bucket.s3-website-us-east-1.amazonaws.com

Both distributions have Alternate domain names configured with corresponding domains.

I configured Error Pages 404 code to respond with /index.html, but when requesting

https://first.mysite.com/doesnotexists it got redirected to https://second.mysite.com

> HEAD /doesnotexists HTTP/2
> Host: first.mysite.com
> user-agent: curl/7.81.0
> accept: */*
> 
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
< HTTP/2 301 
HTTP/2 301 
< content-length: 0
content-length: 0
< location: http://second.mysite.com/
location: http://second.mysite.com/
< date: Fri, 23 Sep 2022 19:02:16 GMT
date: Fri, 23 Sep 2022 19:02:16 GMT
< server: AmazonS3
server: AmazonS3

How it can be possible that I have 301 Permanent redirect to a completely different domain?

0 Answers
Related