Using Cloudflare Page Rules to Point a Root Domain to a GitBook Site


GitBook only allows the usage of subdomains when pointing to a GitBook site. In the free version of GitBook, this can't be changed but an HTTP redirect via a Cloudflare page rule is a cheap, fast, and easy way to send users from a root domain to a subdomain where a GitBook site is hosted.

Example: -> (GitBook site)

Why Not Double CNAME?

Using a CNAME pointer to redirect to via DNS would make the most sense, but Cloudflare doesn't allow double CNAMEs within the Cloudflare network. Instead, a Cloudflare page rule will serve an HTTP 301 redirect to send all users to where the GitBook Site is hosted.

DNS Records

Add a CNAME DNS entry in the domain's DNS zone to point to This is required by GitBook.

Add a 'dummy' DNS a record for the root site to point anywhere. In this case, Cloudflare's resolver is used.

Cloudflare Page Rules

Create a page rule to redirect all traffic to to via a 301 HTTP redirect. Any 301 redirect implementation will work (e.g. PHP on Apache), but serving this rule at the Cloudflare edge will be the fastest.

Last updated