Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

wordpress-redirects: RedirHub Integration Mode for WordPress

The official WordPress plugin for RedirHub Integration Mode. It serves a domain's RedirHub redirects from the WordPress site itself, so the domain's DNS stays where it is: the site downloads the domain's rules file, answers its redirects, proves the domain with the check path, and reports every redirect to RedirHub's analytics.

It implements Integration Mode format v1 and passes its golden sample, like the Caddy, Next.js and Cloudflare Workers clients.

Plugin name and slug RedirHub Redirects, redirhub-redirects
Requires WordPress 5.9+, PHP 7.4+
User-Agent wordpress-redirects/1.0.0
Settings Tools → RedirHub, or REDIRHUB_RULES_URL and REDIRHUB_INTEGRATION_KEY in wp-config.php

Install

Download redirhub-redirects.zip from the latest release (or the release job of CI), upload it under Plugins → Add New → Upload, activate, then follow Tools → RedirHub: paste the rules address and the integration key from the RedirHub dashboard and press Connect. readme.txt is the WordPress.org listing.

How it answers

Request When How
The check path while the plugin file loads 200 token=… etag=…, no-store
An exact rule while the plugin file loads, before the theme and the plugins after it its redirect or frame page
The catch-all template_redirect, last, only when WordPress answers 404 its redirect
The site's 404 shutdown, for hostnames with report404 reported
  • Fast. The parsed rules are kept as data in options that are not autoloaded: a summary (hostnames, check tokens, catch-alls) and the exact paths in 256 parts by hash, so a request reads the summary and the one part its path is in. Nothing is written to the file system.
  • Fails open. Only GET and HEAD on listed hostnames are touched; any error leaves the request to WordPress; a failed download keeps the last good copy.
  • Nobody waits. Downloads (every @refresh seconds, never per request) and reports run after the visitor has the answer: after fastcgi_finish_request()/litespeed_finish_request(), after the plugin's own complete answers, otherwise in WP-Cron. One download at a time across processes.
  • Link options. Unlike the other clients it carries out a link's options as RedirHub's edge does: the password form (the edge's unlock cookie and attempt limit), nobot, nowechat, and further destinations (routing=order in turn, otherwise at random). They can be switched off.
  • Page caches. Answers set DONOTCACHEPAGE; when the rules change, the pages of the changed paths are purged in the cache plugins it knows (all pages for the first copy, a changed catch-all or list of hostnames). A download that follows one of the plugin's early answers leaves the purge to the next request that loads every plugin, since the cache plugins load after it.
  • Admin. Tools → RedirHub: connect (pasting the whole setup text works too), status, RedirHub's last check, analytics, a self-test over HTTP, the rules in use, settings, disconnect. Site Health test and info, an admin notice when downloads keep failing.

Release

Merging to main is releasing (.github/workflows/release.yml):

  1. For a new version, raise it in redirhub-redirects.php (header and REDIRHUB_REDIRECTS_VERSION) and readme.txt (Stable tag, changelog). The merge tags v<version>, attaches the zip to a GitHub release and deploys the plugin and the listing's assets (.wordpress-org/, regenerated with node bin/wporg-assets.mjs after e2e/run.sh) to the directory.
  2. A merge that leaves the version as it is only updates readme.txt (for example a new "Tested up to") and the assets on WordPress.org. A code change therefore always comes with a new version.

CI runs every Monday as well, against the newest WordPress and every supported PHP, so a new release of either shows up as a failing check even when nothing here changed.

After every release, and every Monday, verify-release.yml tests the plugin as users get it: it downloads the package WordPress.org serves, installs it into a fresh WordPress and runs every e2e suite and Plugin Check on it. Locally: PLUGIN=wporg e2e/run.sh (or PLUGIN=wporg:1.2.3).

Develop

composer install
vendor/bin/phpunit            # the core against spec/v1, and edge cases
e2e/run.sh                    # WordPress in Docker: the golden sample over HTTP, scenarios, the admin page in Chromium
WP_IMAGE=wordpress:6-php7.4-apache e2e/run.sh   # the oldest PHP supported
e2e/backend.sh ../backend     # against a checkout of redirhub/backend (see the script)
bin/build-zip.sh              # build/redirhub-redirects.zip
npm install && npm run build:css   # after changing the admin page's classes (assets/src/admin.css)

The admin page uses the RedirHub dashboard's design: its tokens and Inter (assets/src/admin.css, Tailwind CSS 4 with the rh: prefix and no global reset, so nothing leaks into the rest of wp-admin) and lucide icons (node bin/build-icons.mjs writes includes/Admin/Icons.php). The built assets/admin.css is committed; CI checks it matches its source.

e2e/run.sh needs Docker, PHP with curl, and Node with Playwright for the admin suite; it uses ports 80, 18080 and 18081. includes/Core/ is pure PHP (no WordPress) and is what the unit tests and the golden sample exercise; spec/v1/ is a copy of the specification's, checked in CI.

License

Apache License 2.0, see LICENSE. Copyright 2026 RedirHub.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages