Beta single page rules feature

I’ve read all of the documentation, and while it has some examples for fancier stuff like checking out a language and redirecting to a language-specific subdomain, I’m simply trying to: redirect a subdomain on my domain to an outside url.

example: have a domain bought through Cloudflare, it has a www CNAME, and a page rule (from before i learned about redirects) that makes sure the domain itself (and www) points to URL www.otherdomain.com

what I want to do:

add a single redirect to make it so a new subdomain, like ‘search’ points to a different url.

example: search.mycfdomain.com

redirects to www.otherdomain.com

I THINK, through a lot of trial and error, I have to do the following:

  1. create a cname for the new subdomain, point it to ‘@’ in DNS
  2. go to single redirect, and redirect ‘hostname’ and put in ‘search’, and then in the second part but the outside url i want to send traffic to.

this /seems/ to work, sorta, although sometimes it behaves such that ‘search’ and ‘www’ redirect to the same place for a while, but eventually it ends up like it should and ‘www.cfdomain.com’ and ‘search.cfdomain.com’ redirect to different places.

is this how this ‘should’ be done?

ps: thanks in advance. i read all the tutorials i could find too but they’re all order and point to page rules, of which i seem to get less and also various CF pages say to use redirects if possible first lol.

thanks!

This post had to get manually reviewed so not sure if it’s ok but bump.

Redirect Rules should always behave the same way. What may be happening is a chain of redirects, if you have more than one redirect rule, or if the origin has some redirect rules (WordPress, for instance, will redirect from a non-existing path to a similar post.)

If you have the CNAME record for search.example.com as :orange:, you should be able to set the redirect you want.

Unlike in the DNS tab, here you should actually add the full hostname, such as search.example.com.

If you want all requests from search.example.com to go to the same destination, so that

search.example.com
search.example.com/path-a/
search.example.com/path-b/
etc.

all redirect to, say, www.someotherdomain.com, then yes, that’s all you need to do. If you need that query strings be preserved, mark the checkbox.

But if you want each path to redirect to the equivalent path in the new domain, than you’d need to set the redirect to Dynamic and use the concat() function. For example:

concat("https://someotherdomain.com", http.request.uri.path)