Digital Sovereignty for everyone

How it works

Where rules live

Every rule for every site is a row in one table on the main site, {base_prefix}lh_url_redirects. A rule is keyed on host and path rather than on a site ID, so a rule can belong to a domain no site is mapped to. Each row also records the network site its source belongs to (blog_id, 0 for an unmapped domain), purely for listing and filtering.

The table is created on network activation, and on the next admin request if it is missing. Upgrades are keyed on LH_Url_Redirects_Table::schema_version(), stored in the network option lh_url_redirects_schema_version, never on the plugin version.

When a rule fires

  • 404s on any site. On template_redirect at priority 9, so an explicit rule wins over WordPress’s own URL guessing in redirect_canonical(). A URL that resolves to real content is never redirected.
  • Unmapped domains. Multisite sends a request for a domain with no site to the main site’s wp-signup.php?new=<host>. On before_signup_header the plugin looks up that host’s root rule. Only the host survives the bounce, so the path of the original request is lost: point a whole old domain at a new one with an exact / rule or a / prefix rule.

Matching

  • Scheme, port, query string, host case and trailing slashes are ignored, and the path is percent-decoded, so https://Example.org/a%2Cb/ and http://example.org/a,b are the same source.
  • An exact rule matches one path. A prefix rule matches its path and everything below it (/blog matches /blog/post but not /blogroll); the prefix / matches the whole host.
  • An exact rule beats any prefix rule, and among prefix rules the longest wins.

Responses

301, 302, 303, 307 and 308 redirect to the rule’s target, which may be on any domain; the target’s host is allowed for that one redirect only, through wp_safe_redirect(). 410 keeps the theme’s 404 page but sends the Gone status, except on an unmapped domain, where there is no page to show and a minimal Gone page is sent instead. Each fired rule increments its hit count and records the time.

Managing rules

There is no settings or admin screen. Rules are managed through the MCP abilities, which exist on the main site only and require install_plugins. Lookups are cached in a global object-cache group, cleared whenever a rule changes.

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.