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_redirectat priority 9, so an explicit rule wins over WordPress’s own URL guessing inredirect_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>. Onbefore_signup_headerthe 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/andhttp://example.org/a,bare the same source. - An exact rule matches one path. A prefix rule matches its path and everything below it (
/blogmatches/blog/postbut 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.