Skip to main content

Setting Up Your Domain on Cloudflare

Last updated: January 1, 2026

Setting up your domain on Cloudflare provides enhanced security, performance, and caching for your website. This guide covers essential configuration, including how to fix the common "Site not found" error when visitors access your site without the www prefix.

How do I create a new Cloudflare website?

Follow these steps to deploy an Astro site from GitHub to Cloudflare Pages with a custom subdomain.

Step 1: Create and push your GitHub repo

Go to GitHub.com > Repositories. Create a new repository with a Node .gitignore. Open Claude Code and say “make this an Astro landing page”, and merge in the changes. Make sure your project builds successfully locally before deploying.

Step 2: Start creating a Cloudflare Pages application

  1. Go to Cloudflare Dashboard
  2. Navigate to Workers & Pages in the left sidebar
  3. Click Create Application
  4. Important: Pause on this page—don’t click the main buttons yet!

Step 3: Switch to Pages deployment

Look for the small text link that says “Looking to deploy Pages? Get started” and click it. This switches you from Workers to Pages deployment.

Step 4: Import your GitHub repository

  1. Click Import existing repository
  2. Connect your GitHub account if prompted
  3. Select your repository from the list

Step 5: Configure build settings

Update the build settings with these values:

SettingValue
Build commandnpm run build
Build output directory/dist

Click Save and Deploy to start the deployment.

Step 6: Wait for deployment

Your site will deploy in a few minutes. You’ll see a success message: “Success! Your project is deployed to Region: Earth”.

Step 7: Add a custom domain

  1. Click Add a custom domain
  2. Click Set up domain
  3. Enter your subdomain in the format <site>.silvermine.ai (e.g., example.silvermine.ai)
  4. Naming convention: Match the GitHub repo name—if the repo is bob.silvermine.ai, use bob.silvermine.ai as the custom domain
  5. Click Activate domain

Step 8: Wait for DNS propagation

Your domain will be ready in approximately 5 minutes. Cloudflare automatically handles the DNS configuration for subdomains on domains already managed by Cloudflare.


Why do users see “Site not found” when www. is excluded?

When your website is configured to serve content from www.yourdomain.com, visitors who type just yourdomain.com (without the www) may see a “Site not found” error. This happens because:

  1. DNS records point to www only - Your hosting is configured for the www subdomain
  2. No redirect rule exists - There’s nothing telling Cloudflare to forward non-www traffic to www
  3. Different hostnames - Technically, example.com and www.example.com are different hostnames

The solution is to create a Page Rule that automatically forwards all non-www traffic to your www domain.

How to create a forwarding rule

  1. Log in to your Cloudflare Dashboard

  2. Select your domain from the list

  3. In the left sidebar, click on Rules and then select Page Rules (or just “Rules” if you don’t see the submenu immediately)

  4. Click the blue Create Page Rule button

  5. Configure the rule with these settings:

FieldValue
URL (Field 1)yourdomain.com/*
Pick a Setting (Field 2)Forwarding URL
Select Status Code (Field 3)301 - Permanent Redirect
Destination URL (Field 4)https://www.yourdomain.com/$1
  1. Click Save and Deploy Page Rule

Understanding the configuration

  • yourdomain.com/* - The asterisk matches any path after your domain
  • 301 - Permanent Redirect - Tells browsers and search engines this is a permanent change (good for SEO)
  • $1 in the destination - This captures whatever was after the slash and appends it to the new URL

Example redirects

Visitor TypesRedirects To
silvermine.aihttps://www.silvermine.ai
silvermine.ai/contacthttps://www.silvermine.ai/contact
silvermine.ai/blog/post-titlehttps://www.silvermine.ai/blog/post-title

Without the $1, all paths would redirect to just the homepage, breaking deep links.


How do I redirect from an old domain to a new one?

Silvermine.ai used to be www.silvermineai.com (sometimes we still send emails from our old domain because so much is connected to it). Here, we show how we set up a redirect from www.silvermineai.com to www.silvermine.ai.

Why this matters: If done incorrectly, your users will get a 404. For example, if there’s a link on the internet to www.silvermineai.com/about, they’ll land on a page that doesn’t exist anymore.

Part 1: Redirecting the old domain

Goal: Catch anyone typing your old domain name (with or without “www” or any path like “/about”) and send them to the new site.

The DNS setup (the “dummy” target)

First, create a DNS record to ensure Cloudflare catches the traffic on your old domain:

SettingValue
TypeA Record
Name* (Wildcard) or @ (Root)
IPv4 Address192.0.2.1 (placeholder address)
Proxy StatusProxied (Orange Cloud)

Note: The IP 192.0.2.1 is a documentation-reserved address. It doesn’t matter what it points to because Cloudflare will intercept the traffic before it reaches that IP.

The redirect rule

Create a Page Rule to catch everything on the old domain:

FieldValue
URL*silvermineai.com/*
SettingForwarding URL (301 Permanent Redirect)
Destinationhttps://www.silvermine.ai/$2

The $2 captures the path from the second wildcard, preserving deep links.

Part 2: Fixing the new root domain

Goal: Ensure first-time users who forget to type “www” on your new domain still get to the site.

FieldValue
URLsilvermine.ai/*
SettingForwarding URL (301 Permanent Redirect)
Destinationhttps://www.silvermine.ai/$1

Summary of results

User TypesRedirects To
silvermine.aihttps://www.silvermine.ai
silvermine.ai/abouthttps://www.silvermine.ai/about
silvermineai.comhttps://www.silvermine.ai
silvermineai.com/contacthttps://www.silvermine.ai/contact
www.silvermineai.comhttps://www.silvermine.ai
www.silvermineai.com/serviceshttps://www.silvermine.ai/services

All paths are preserved, so existing links across the internet continue to work.

Looking for expert guidance? Schedule a free consult:

Book a Free Consultation