Text in Expression Editor:
Text after Path > Rewrite to… > Dynamic:
Modify both the URI path and Host
header of incoming requests using Transform Rules and Origin Rules.
To change URI Path and Host Header on incoming requests simultaneously:
/uploads
from the path:
Text in Expression Editor:
Text after Path > Rewrite to… > Dynamic:
The regex_replace()
function replaces the /uploads/
part of the path with /
, changing /uploads/example.jpg
to /example.jpg
.
Text in Expression Editor:
Text after Host Header > Rewrite to…:
This will set the Host header to example.com
for matching requests.
Optional: To route requests to a different origin (DNS target), use DNS override:
Text after DNS Record > Override to…:
This will route requests to the DNS target of example.com
instead of your default DNS record.
This setup routes traffic from https://<YOUR_SOURCE_HOSTNAME>/uploads/*
to https://<YOUR_TARGET_HOSTNAME>/*
. Ensure the filters for Transform Rules and Origin Rules (or Cloud Connector) are precise to avoid unintended rule executions.
Remember that rules are evaluated in sequence, so Transform Rules run before Origin Rules or Cloud Connector.
Make sure to replace example.com
with your actual hostname and adjust the example paths according to your setup. By following these steps, you can effectively manage both URI paths and Host headers to route traffic appropriately and optimize request handling.