Redirect root domain to www using Cloudflare

Nov 3, 2024

Cloudflare

I assume you already moved your domain to Cloudflare.

  1. On the sidebar, click Rules -> Redirect Rules.
  2. Click Create Rule button.
  3. Fill the the Rule name whatever you want.
  4. Choose Custom filter expression
  5. Follow this configuration:
  • Field: Hostname
  • Operator: Equals
  • Value: example.com
  • Type: Dynamic
  • Expression: concat("https://www.example.com", http.request.uri.path)
  • Status Code: 301
  1. Check Preserve query string checkbox

    Configuration example
  2. Click Save button.

Masred