logo

Should I use path-style or virtual hosted-style S3 URLs?

And what is the difference?

Joel Clermont
Joel Clermont
2025-10-16

When you work with Amazon S3 (or compatible services), there are two ways to address your buckets: virtual-hosted style and path-style.

Let's say you have a bucket named my-bucket in the us-east-1 region.

Virtual-hosted URL: https://my-bucket.s3.us-east-1.amazonaws.com/my-file.pdf
Path-style URL: https://s3.us-east-1.amazonaws.com/my-bucket/my-file.pdf

Which one should you use?

AWS really wants you to use the virtual-hosted style. It's the default for the AWS SDKs, and they've been trying to deprecate path-style access for years.

Although AWS keeps pushing back the deadline, it will probably happen eventually, so it's best to get used to it now.

But what if you're using a local S3-compatible service like MinIO for development? Using the virtual-hosted style can be tricky because it often requires additional DNS configuration and certificate management.

How can we get the simplicity of path-style access for local development without losing the benefits of virtual-hosted style for production?

Laravel makes this quite simple!

In your local .env file, you can set the AWS_USE_PATH_STYLE_ENDPOINT variable to true.

And then in production, you would leave that same environment variable set to the default value of false.

Here to help,

Joel

P.S. Struggling with S3 configuration or file storage in your Laravel app? Let's debug it together.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.