> For the complete documentation index, see [llms.txt](https://www.blakejarvis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.blakejarvis.com/miscellaneous-articles/using-cloudflare-page-rules-to-point-a-root-domain-to-a-gitbook-site.md).

# 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:** blakejarvis.com -> [www.blakejarvis.com](http://www.blakejarvis.com) (GitBook site)

### Why Not Double CNAME?

Using a CNAME pointer to redirect blakejarvis.com to [www.blakejarvis.com](http://www.blakejarvis.com) 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 [www.blakejarvis.com](http://www.blakejarvis.com) where the GitBook Site is hosted.

### DNS Records

Add a CNAME DNS entry in the domain's DNS zone to point [www.blakejarvis.com](http://www.blakejarvis.com) to hosting.gitbook.io. This is required by GitBook.

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

![](/files/-MXtLrNBY9W-4_to0EX6)

### Cloudflare Page Rules

Create a page rule to redirect all traffic to blakejarvis.com to [www.blakejarvis.com](http://www.blakejarvis.com) 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.

![](/files/-MXtLnLfl3y5Fkl-0T9g)
