How do I get a virtual-hosted–style AWS S3 bucket instead of Path-Style?

Viewed 124

I'm unable to get a virtual-hosted–style AWS S3 bucket URL for my static files. As per AWS' Customizing Amazon S3 URLs with CNAMEs, I need to create a bucket with the name static.domain.com. But, when I do that and upload a file, the Object URL is a Path-Style URL:-

What I'm getting >> https://s3.eu-west-1.amazonaws.com/static.domain.com/testfile.jpg

What it should be >> https://static.domain.com.s3.eu-west-1.amazonaws.com/testfile.jpg

To get prettier and SEO friendly URL, I'm using Cloudflare and setting the CNAME accordingly, but I can only do that with a virtual-hosted–style bucket URL.

I've tried setting the bucket name as static-domain-name, but that doesn't work as well. I got the S3 permission denied error S3 couldn't find a bucket named static.domain.com.

0 Answers
Related