CloudFront (CF) is forwarding a request to a specific origin based on the URI pattern (ex. https://domain -> CloudFront -> /uri -> s3://bucket).
You can attach a CF Function to the distribution and rewrite the URI before it is forwarded to the origin.
These are examples: