diff --git a/README.md b/README.md index 57636ae..9a90e4f 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,4 @@ The deployment token comes from a local `cloudhal deploy` (`.cloudhal/deploy/sec ## Domains -`cloudhal.com` serves the site and `studio.cloudhal.com` serves Studio (`domains` in `cloudhal.json`; the deploy adds both as Workers custom domains, which turns the workers.dev addresses off). `www.cloudhal.com` should 301 to `https://cloudhal.com` through a Cloudflare Redirect Rule on the zone. +`cloudhal.com` serves the site and `studio.cloudhal.com` serves Studio (`domains` in `cloudhal.json`; the deploy adds both as Workers custom domains, which turns the workers.dev addresses off). `www.cloudhal.com` answers with a 301 to `https://cloudhal.com` (path and query kept): `domains.redirects` in `cloudhal.json`, set with `cloudhal domain set cloudhal.com --redirect www.cloudhal.com`, served by the site Worker as a custom domain. Adding a new redirect host needs a deploy with zone permissions (a local `cloudhal deploy`); the Workers Builds token only redeploys existing domains. diff --git a/cloudhal.json b/cloudhal.json index 7e7405e..a6b9698 100644 --- a/cloudhal.json +++ b/cloudhal.json @@ -9,6 +9,9 @@ }, "domains": { "site": "cloudhal.com", - "studio": "studio.cloudhal.com" + "studio": "studio.cloudhal.com", + "redirects": [ + "www.cloudhal.com" + ] } } diff --git a/wrangler.jsonc b/wrangler.jsonc index 143d908..f403c9e 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -31,12 +31,18 @@ "CLOUDHAL_SITE_ID": "site_8DTHH9QRG8CAMYKHENBW", "CLOUDHAL_ANALYTICS": "on", "CLOUDHAL_ANALYTICS_DEFAULTS": "{\"enabled\":true,\"uniqueVisitors\":false,\"vitalsOneIn\":5}", - "CLOUDHAL_SITE_HOSTS": "cloudhal.com" + "CLOUDHAL_SITE_HOSTS": "cloudhal.com", + "CLOUDHAL_REDIRECT_HOSTS": "www.cloudhal.com", + "CLOUDHAL_REDIRECT_TO": "cloudhal.com" }, "routes": [ { "pattern": "cloudhal.com", "custom_domain": true + }, + { + "pattern": "www.cloudhal.com", + "custom_domain": true } ], "cache": {