I wanted to run Google Ads for one of my side projects, but I noticed a problem: Google was displaying my domain as www.example.com
, even though I hadn’t set up a www subdomain. This meant that if anyone tried to visit www.example.com
, they’d find nothing. Since I’m not using a reverse proxy and rely on Cloudflare (CF) rules to direct traffic, I figured the best solution was to set up the www subdomain and handle everything on the Cloudflare side.
Here’s how I did it:
www.example.com/*
. This pattern catches all URLs starting with www.example.com.https://example.com/$1
. The $1
ensures that any subdirectory path from the original URL is appended to the new URL.By following these steps, any request to www.example.com will be seamlessly redirected to example.com, preserving any subdirectory paths.