Dynamic redirects based on matching cname pattern, passing matches back to location

I’m trying to match part of a hostname, then redirect to an external domain with the match included in the path.

Current approach:

  • Rules → Transform Rule → HTTP Header Modification rule
  • Match hostname regex (one|two|three).hostname.com
  • Set static header Location = https://newhostname.com/newpath/$1

Of course, the last line doesn’t work as expected. Is there a different way to accomplish this?

Thanks!

I don’t think Transform will let you rewrite the hostname, but you can rewrite the path.

I’m on a mobile device, so I can’t experiment, but how about:

  1. transform and add the hostname to the path
  2. page rule * match for that path and redirect
1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.