Steps to Forward the Root Domain to www Subdomain Using Cloudflare

Steps to Forward the Root Domain to www Subdomain Using Cloudflare

  1. Add your domain to Cloudflare: This is the first step to set up any kind of redirect. Make sure that your domain has a proxied DNS A or CNAME record that properly resolves DNS queries.

  2. Create a DNS record for the www subdomain: This record can point to any IP address since all traffic will be redirected prior to reaching the address.

  3. Set up a Page Rule for redirection: In the Cloudflare dashboard, navigate to the Page Rules section. Here, you will create a new rule for your root domain ( to redirect to your www subdomain (

    • Enter the URL pattern: The pattern should match your root domain. For instance, you can use ** to match all paths under your root domain.

    • Choose Forwarding URL: In the “Pick a Setting” dropdown, choose “Forwarding URL”.

    • Select status code: Choose 301 - Permanent Redirect or 302 - Temporary Redirect, depending on your needs. A 301 redirect is typically used for permanent URL changes, while a 302 redirect is used for temporary URL changes.

    • Enter the destination URL: This is the URL you want to redirect to, which in this case would be your www subdomain. To keep the path and query string from the original URL, use variables like $1 and $2 that correspond to the wildcard parts of your URL pattern. For example, you could use$1 as your destination URL.

    • Save and Deploy Page Rule: Once you’ve set up the rule as desired, select “Save and Deploy Page Rule” to activate the redirect.

Remember, Page Rules require a proxied DNS record to work, and they will not apply to subdomains that do not exist in DNS or are not being directed to Cloudflare.