Bunny CDN: How to redirect Root Domain to Subdomain

Three effective and technically robust methods to seamless redirection using Bunny DNS, ensuring proper domain resolution and optimal performance.

· Software Engineering
By Jan Brennenstuhl · 3min read

Bunny CDN: How to redirect Root Domain to Subdomain

Although technically no longer necessary, the www subdomain is deeply ingrained in internet history and user habits. Redirecting root domains (like jbspeakr.cc) to its www subdomain (www.jbspeakr.cc) offers benefits, especially when using a content delivery network (CDN) or caring about search engine optimization (SEO).

In this article I share three different aproaches to redirect a root domain to its www subdomain when using Bunny CDN with Bunny DNS. All three approaches are technically sound and working solutions, returning proper A records for the domain root.

Bunny.net Logo

Looking for an European CDN? Join Team Bunny!

Option 1: Redirect Record (RDR)

Bunny DNS supports the creation of special redirect records. While the initial resolution happens at the DNS level, Bunny automatically applies HTTP redirects, instructing the browser ultimately to make a request to the redirected location.

Configuring a new redirect record is as simple as heading over to Bunny DNS and choosing RDR as record type in the “Add DNS Record” prompt. Setting up a redirect record works as long as you don’t already have the hostname registered.

Bunny DNS – Redirect Record config

Option 2: Pull Zone Record (PZ)

A “Pull Zone” in Bunny CDN is a fundamental concept that defines how static assets are delivered using Bunny’s network of edge servers. A PZ record is a Bunny-custom, special DNS record type that provides some level of abstraction when glueing a domain to a “Pull Zone”. Instead of directly resolving to an IP address, Bunny DNS understands that requests for that particular domain should be directed to its CDN infrastructure associated with the corresponding “Pull Zone”.

Configuring a new “Pull Zone” record is as simple as heading over to Bunny DNS and choosing PZ as record type in the “Add DNS Record” prompt. Prerequisit is an existing “Pull Zone” that the root domain should point to. The actual HTTP redirect would then be handled by a dedicated “Edge Rule”.

Bunny DNS – Pullzone Record config

Option 3: Canonical Name Record (CNAME)

Last but not least, Bunny DNS allows to create CNAME records also for root domains. This is possible (and also returns an A record) as Bunny transparently performs CNAME flattening under the hood.

Configuring a new canonical name record is as simple as heading over to Bunny DNS and choosing CNAME as record type in the “Add DNS Record” prompt. The actual HTTP redirect would then be handled by a dedicated “Edge Rule”.

Bunny DNS – CNAME Record config

Dedicated Edge Rule

In case a root domain points to a Bunny CDN “Pull Zone” either by using either a PZ or CNAME record (Option 2 or Option 3), the actual HTTP redirect (301) needs to be applied using a dedicated “Edge Rule” like this:

ActionValueStatus Code
Redirect to URLhttps://www.jbspeakr.cc{{path}}301
ConditionMatchValue
Request URLAny*://jbspeakr.cc/*

Bunny CDN – Edge Rule

Summary

In summary, while the www subdomain isn’t a technical necessity in the modern web, redirecting root domains to it is a best practice for SEO consistency, technical flexibility, and user experience. It ensures that websites are treated as a single entity by search engines and provides a consistent and potentially more reliable experience for visitors.

Bunny.net DNS supports three different approaches for redirecting a root domain to its www subdomain. All result in perfecly fine DNS configs and high-speed resolution when paired with Bunny CDN.

Portrait of Jan Brennenstuhl
Written by Jan Brennenstuhl

As a Principal Software Engineer, Jan Brennenstuhl has a focus on usable security and app/web authentication. He leads authentication experience engineering teams and spent years with building identity providers based on OIDC.