This example demonstrates how to use Cloudflare Snippets to:
- Reroute incoming requests to a different origin.
- Prepend a directory to the URL path.
- Remove specific segments from the URL path.
This configuration will perform the following rewrites:
Request URL | URL after rewrite |
---|
https://subdomain.example.com/foo | https://example.com/new-path/foo |
https://example.com/remove-me/bar | https://example.com/new-path/bar |
https://example.net/remove-me | https://example.com/new-path |
Thank you for helping improve Cloudflare's documentation!