New to Cloudflare so apologies if this is quite a basic question.
I just want to verify that it is possible to control the public URLs for our images so that they conform to our desired naming convention, rather than having to use the full URL of the source URL from the DAM that is serving them to Cloudflare.
Specifically, the DAM is including an idhash field within the URL that is not part of our naming convention, example below:
So, we want to remove the idhash and extra / (12766cdf4a20e5e4/) for the URL that we use on our website to retrieve the image. I’m just looking for confirmation that this is possible to do with Cloudflare or are my expectations unrealistic. I’ve read about Workers, URL Forwarding, Redirects, in the Cloudflare user documentation, so assume if it’s possible, then it would be one of these functions that we could use to achieve what we are looking for.
Thanks in advance for any help received.
What do you mean by “received”? Do you want to change the URL when it is requested or do you want to change the HTML output your servers sends (via Cloudflare) to the client?
So you basically want to replace m/16-character-string with images, right?
Neither redirects nor page rules would help you here, you’d need a custom worker for that. You’d essentially take whatever your server returns and run a search-and-replace to do aforementioned task.
Yes, exactly that, we want to replace m/16-character-string with images.
I think I’ve seen an example Worker script that does something similar. I will take a look at the html-rewriter link, thanks for all hour help, it’s given me the reassurance that my expectation is not completely unrealistic.
Not unrealistic at all. That should be fairly straightforward with some custom JavaScript code.
Workers are pretty powerful in this context, however they are typically a paid feature (unless you can work within the limits of the free plan). HTMLRewriter is somewhat new and still limited, but should be able to do the trick in your case anyhow.