Route /images to an S3 Bucket
Route requests with a URI path starting with /images to a specific AWS S3 bucket using Cloud Connector.
To route requests to /images on your domain to an AWS S3 bucket:
- 
In the Cloudflare dashboard, go to the Cloud Connector page.
Go to Cloud Connector - 
Select Amazon S3 as your cloud provider.
 - 
Enter the bucket URL. You can structure the URL in two ways:
- Subdomain-style URL: Set the hostname to 
<BUCKET_NAME>.s3.amazonaws.com. In this case, your files should be organized in the root of the bucket, meaning the URI path will map directly to the file. For example,https://<YOUR_HOSTNAME>/images/file.jpgwill map tohttps://<BUCKET_NAME>.s3.amazonaws.com/images/file.jpg. - URI path-style URL: Set the hostname to 
s3.amazonaws.com. Here, your bucket must include a folder namedimages, and files should be placed inside this folder. The URI path will then include the bucket name, likehttps://<YOUR_HOSTNAME>/<BUCKET_NAME>/images/file.jpgmapping tohttps://s3.amazonaws.com/<BUCKET_NAME>/images/file.jpg. 
 - Subdomain-style URL: Set the hostname to 
 - 
(Optional) Use URL Rewrite Rules to adjust the URL structure. For example, you can create a URL rewrite that changes
/imagesto/<BUCKET_NAME>/imagesto match the URI path-style URL structure. - 
(Optional) Use Cache Rules to adjust the caching behavior for objects returned from the bucket. For example, you can create a cache rule that caches every returned object matching the
/images/*URI path for seven days:- If incoming requests match > Custom filter expression: 
(starts_with(http.request.uri.path, "/images/")) - Cache eligibility: Eligible for cache
- Edge TTL > Ignore cache-control header and use this TTL: 7 days
 
 
 - If incoming requests match > Custom filter expression: 
 - 
Select Next and enter a descriptive name like
Route images to S3in Cloud Connector name. - 
Under If, select Custom filter expression and enter the following expression:
http.request.full_uri wildcard "http*://<YOUR_HOSTNAME>/images/*"
Replace<YOUR_HOSTNAME>with desired hostname. - 
Select Deploy to activate the rule.
 
This setup will route all traffic matching http*://<YOUR_HOSTNAME>/images/* (HTTPS and HTTP requests) to your S3 bucket. Make sure to replace <YOUR_HOSTNAME> with your actual hostname and adjust the example paths according to your setup.
Was this helpful?
- Resources
 - API
 - New to Cloudflare?
 - Directory
 - Sponsorships
 - Open Source
 
- Support
 - Help Center
 - System Status
 - Compliance
 - GDPR
 
- Company
 - cloudflare.com
 - Our team
 - Careers
 
- © 2025 Cloudflare, Inc.
 - Privacy Policy
 - Terms of Use
 - Report Security Issues
 - Trademark