v1 Implementation Notes

Path Remapping implementation notes

4 Workers work together in this solution;

  • cmsitem-redirect handles all redirects from the source path to the destination path.

  • cmsitem-redirect-page handles all rewrites from source path to the destination path, as well as canonical URL changes.

  • cmsitem-redirect-sitemap handles the path remapping in the sitemap.xml

  • debug-rewrite handles all other pages, this is used for indirectly proxied sites, often in a test setup.

All of these draw from a central configuration file stored in the CONFIG KV store;

The key is your base domain, followed by :cmsitem-redirect;

e.g. mydomain.com:cmsitem-redirect

The value is a JSON config chunk that all of the cmsitem-redirect workers use, e.g.;

{
  "version": 1,
  "origin": "https://www.mysite.com", // optional, for indirect-proxy setup
  "type": "static", 
  "map": {
    "/blog/my-article": "/path/that/i/want/to/use" 
  }
}

When modifying your config, it's essential to make sure your JSON is valid. We recommend you protect yourself from mistakes with these two practices;

  • Always validate your JSON, before setting a new config.

  • Always save your previous JSON config somewhere safe before changing it.

Worker routes;

Route ( example )WorkerNotes

*mydomain.com/blog/*

cmsitem-redirect

Define the routes you want to be redirected here.

*mydomain.com/path/*

cmsitem-redirect-page

Define the routes wher

*mydomain.com/sitemap.xml

cmsitem-redirect-sitemap

Define the route to your sitemap.xml.

*mydomain.com/*

debug-rewrite

Only needed for indirect proxy setups.

Note all config work is managed by the Config class within the cmsitem-redirect worker

Future

  • Add dynamic map types

    • Support hiding of dynamic pages

Map Types

static, stored in KV as JSON

dynamic, generated on site, on a hidden page

Last updated