githubEdit

CF_REDIRECT

circle-exclamation

CF_REDIRECT uses Cloudflare-specific features ("Forwarding URL" Page Rules) to generate a HTTP 301 permanent redirect.

If any CF_REDIRECT or CF_TEMP_REDIRECT functions are used then dnscontrol will manage all "Forwarding URL" type Page Rules for the domain. Page Rule types other than "Forwarding URL" will be left alone.

circle-exclamation

HTTP 301 redirects are cached by browsers forever, usually ignoring any TTLs or other cache invalidation techniques. It should be used with great care. We suggest using a CF_TEMP_REDIRECT initially, then changing to a CF_REDIRECT only after sufficient time has elapsed to prove this is what you really want.

This example redirects the bare (aka apex, or naked) domain to www:

dnsconfig.js
D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
  CF_REDIRECT("example.com/*", "https://www.example.com/$1"),
);

Last updated