Auto Redirect Root Domain to www

If your subdomain is www, you must redirect the root domain to www.

Example:

https://example.com (https://example.com) → https://www.example.com (https://www.example.com)

Cloudflare

Open Cloudflare Dashboard → select your domain

Go to Rules → Overview → Create rule (Redirect Rules)

When incoming requests match

• Wildcard pattern

• Request URL: https://example.com/*

• Target URL: https://www.example.com/${1}

• Status code: 301

• Preserve query string: Enabled

​Save & Enable

This ensures all root-domain traffic automatically redirects to www.

Reference: https://developers.cloudflare.com/rules/url-forwarding/examples/redirect-root-to-www/ (https://developers.cloudflare.com/rules/url-forwarding/examples/redirect-root-to-www/)