PHPackages                             automattic/wpcom-legacy-redirector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. automattic/wpcom-legacy-redirector

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

automattic/wpcom-legacy-redirector
==================================

WordPress plugin for handling large volumes of legacy redirects in a scalable manner.

1.3.0(8y ago)25140.9k—5.6%16[7 PRs](https://github.com/Automattic/WPCOM-Legacy-Redirector/pulls)GPL-2.0+PHPCI passing

Since Jul 7Pushed 2mo ago72 watchersCompare

[ Source](https://github.com/Automattic/WPCOM-Legacy-Redirector)[ Packagist](https://packagist.org/packages/automattic/wpcom-legacy-redirector)[ Docs](https://github.com/Automattic/WPCOM-Legacy-Redirector)[ RSS](/packages/automattic-wpcom-legacy-redirector/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (14)Used By (0)

WPCOM Legacy Redirector
=======================

[](#wpcom-legacy-redirector)

Stable tag: 2.0.0-alpha Requires at least: 6.4 Tested up to: 6.7 Requires PHP: 8.2 License: GPLv2 or later License URI: Tags: redirects, 301, legacy, migration, seo Contributors: automattic, WordPress VIP

A WordPress plugin for handling legacy redirects in a scalable manner. Designed for high-traffic sites with large volumes of redirects.

At a Glance
-----------

[](#at-a-glance)

- **Scalable**: Handles thousands of redirects efficiently using MD5-indexed lookups
- **Admin UI**: Add and manage redirects through the WordPress admin
- **WP-CLI support**: Bulk import/export via command line
- **Multisite compatible**: Works on single sites and multisite networks
- **Query parameter preservation**: Optionally preserve UTM and other tracking parameters
- **VIP-ready**: Built for WordPress VIP environments

Installation
------------

[](#installation)

1. Upload the plugin folder to `/wp-content/plugins/` or install via the WordPress admin
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Navigate to **Tools &gt; Redirects** to add or manage redirects

Usage
-----

[](#usage)

### Adding Redirects via Admin

[](#adding-redirects-via-admin)

1. Go to **Tools &gt; Redirects &gt; Add Redirect**
2. Enter the "Redirect From" path (e.g., `/old-page`)
3. Enter the "Redirect To" destination (URL or post ID)
4. Click "Add Redirect"

### Adding Redirects via WP-CLI

[](#adding-redirects-via-wp-cli)

```
# Add a single redirect
wp wpcom-legacy-redirector insert-redirect /old-page https://example.com/new-page

# Redirect to an internal post by ID
wp wpcom-legacy-redirector insert-redirect /old-page 123

# Import redirects from CSV
wp wpcom-legacy-redirector import-from-csv /path/to/redirects.csv

# Export redirects to CSV
wp wpcom-legacy-redirector export-to-csv /path/to/export.csv
```

### Programmatic Usage

[](#programmatic-usage)

```
use Automattic\LegacyRedirector\Domain\Destination;
use Automattic\LegacyRedirector\Domain\SourceUrl;
use function Automattic\LegacyRedirector\container;

// Get the redirect manager via the helper function (recommended for third-party code)
$manager = container()->manager();

// Add a redirect to an external URL
$source      = SourceUrl::from_string( '/old-page' );
$destination = Destination::from_mixed( 'https://example.com/new-page' );
$result      = $manager->create_redirect( $source, $destination );

if ( $result->is_error() ) {
    // Handle error: $result->error_code(), $result->error_message()
}
$redirect_id = $result->redirect_id();

// Add a redirect to an internal post by ID
$source      = SourceUrl::from_string( '/another-old-page' );
$destination = Destination::from_mixed( $post_id );
$result      = $manager->create_redirect( $source, $destination );

// Check if a redirect exists and get its data
$redirect_data = container()->executor()->get_redirect_data( '/old-page' );
if ( $redirect_data ) {
    $redirect_url    = $redirect_data['url'];
    $redirect_status = $redirect_data['status_code'];
}
```

Multisite Support
-----------------

[](#multisite-support)

The plugin works on WordPress multisite installations:

- **Per-site redirects**: Each site manages its own redirects independently
- **No cross-site leakage**: Redirects on Site A do not affect Site B
- **WP-CLI support**: Use `--url=site.example.com` to manage specific sites

### WP-CLI Multisite Examples

[](#wp-cli-multisite-examples)

```
# Add redirect on specific site
wp wpcom-legacy-redirector insert-redirect /old /new --url=site2.example.com

# Export redirects from specific site
wp wpcom-legacy-redirector export-to-csv /path/to/export.csv --url=site2.example.com
```

How It Works
------------

[](#how-it-works)

Redirects are stored as a custom post type (`vip-legacy-redirect`) with:

- **MD5 hash** of the source URL in `post_name` (indexed for fast lookups)
- **Original URL** in `post_title` (human-readable)
- **Destination** as either `post_parent` (internal) or `post_excerpt` (external)

The plugin intercepts 404 requests early (priority 0 on `template_redirect`) and performs a redirect if a match is found.

Hooks and Filters
-----------------

[](#hooks-and-filters)

### Preserve Query Parameters

[](#preserve-query-parameters)

By default, query parameters are stripped during redirect lookup. To preserve specific parameters (like UTM codes):

```
add_filter( 'wpcom_legacy_redirector_preserve_query_params', function( $params, $url ) {
    return array( 'utm_source', 'utm_medium', 'utm_campaign' );
}, 10, 2 );
```

### Modify Redirect Status Code

[](#modify-redirect-status-code)

Change the HTTP status code (default: 301):

```
add_filter( 'wpcom_legacy_redirector_redirect_status', function( $status, $url ) {
    return 302; // Temporary redirect
}, 10, 2 );
```

### Modify Request Path

[](#modify-request-path)

Alter the path before redirect lookup:

```
add_filter( 'wpcom_legacy_redirector_request_path', function( $path ) {
    return strtolower( $path ); // Case-insensitive matching
} );
```

WP-CLI Commands
---------------

[](#wp-cli-commands)

CommandDescription`insert-redirect`Add a single redirect`import-from-csv`Bulk import from CSV file`import-from-meta`Import from post meta`export-to-csv`Export all redirects to CSV`find-domains`List destination domainsFor detailed command options, run `wp help wpcom-legacy-redirector`.

Documentation
-------------

[](#documentation)

See the [Wiki](https://github.com/Automattic/wpcom-legacy-redirector/wiki) for detailed documentation.

Support
-------

[](#support)

- **Bug reports &amp; features**: [GitHub Issues](https://github.com/Automattic/wpcom-legacy-redirector/issues)
- **VIP customers**: Contact [WordPress VIP Support](https://wpvip.com/wordpress-vip-enterprise-support/)

Please use GitHub Issues only for bug reports and feature requests, not general support questions.

Contributing
------------

[](#contributing)

We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.

License
-------

[](#license)

Licensed under `GPL-2.0-or-later`. See [LICENSE](./LICENSE) for details.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance58

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~443 days

Total

3

Last Release

2716d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba7751eebec0f74a4963e9a062f49e58222b97872bf193d95f0505f3df321d09?d=identicon)[GaryJones](/maintainers/GaryJones)

![](https://www.gravatar.com/avatar/7c5869ecbb8e0eac7e8b8e0f3cf7bdd8d5fcdc4abc10a72281872c53f8639d44?d=identicon)[automattic](/maintainers/automattic)

---

Top Contributors

[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (210 commits)")[![mikeyarce](https://avatars.githubusercontent.com/u/3220162?v=4)](https://github.com/mikeyarce "mikeyarce (67 commits)")[![ovidiul](https://avatars.githubusercontent.com/u/537751?v=4)](https://github.com/ovidiul "ovidiul (60 commits)")[![rclachance](https://avatars.githubusercontent.com/u/2522431?v=4)](https://github.com/rclachance "rclachance (27 commits)")[![mjangda](https://avatars.githubusercontent.com/u/86105?v=4)](https://github.com/mjangda "mjangda (12 commits)")[![bdtech](https://avatars.githubusercontent.com/u/1937447?v=4)](https://github.com/bdtech "bdtech (10 commits)")[![mdbitz](https://avatars.githubusercontent.com/u/5784663?v=4)](https://github.com/mdbitz "mdbitz (10 commits)")[![philipjohn](https://avatars.githubusercontent.com/u/136342?v=4)](https://github.com/philipjohn "philipjohn (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![rodruiz](https://avatars.githubusercontent.com/u/10534494?v=4)](https://github.com/rodruiz "rodruiz (6 commits)")[![emrikol](https://avatars.githubusercontent.com/u/3060583?v=4)](https://github.com/emrikol "emrikol (4 commits)")[![kjbenk](https://avatars.githubusercontent.com/u/5174208?v=4)](https://github.com/kjbenk "kjbenk (4 commits)")[![dhusakovic](https://avatars.githubusercontent.com/u/2406820?v=4)](https://github.com/dhusakovic "dhusakovic (2 commits)")[![seanlanglands](https://avatars.githubusercontent.com/u/565973?v=4)](https://github.com/seanlanglands "seanlanglands (2 commits)")[![rebeccahum](https://avatars.githubusercontent.com/u/16962021?v=4)](https://github.com/rebeccahum "rebeccahum (2 commits)")[![spencermorin](https://avatars.githubusercontent.com/u/2508727?v=4)](https://github.com/spencermorin "spencermorin (1 commits)")[![Nikschavan](https://avatars.githubusercontent.com/u/2931091?v=4)](https://github.com/Nikschavan "Nikschavan (1 commits)")[![jigneshnakrani088](https://avatars.githubusercontent.com/u/9261540?v=4)](https://github.com/jigneshnakrani088 "jigneshnakrani088 (1 commits)")[![diksha-nts](https://avatars.githubusercontent.com/u/66629036?v=4)](https://github.com/diksha-nts "diksha-nts (1 commits)")[![bswatson](https://avatars.githubusercontent.com/u/303029?v=4)](https://github.com/bswatson "bswatson (1 commits)")

---

Tags

redirectswordpresswordpress-pluginwpvip-plugin

### Embed Badge

![Health badge](/badges/automattic-wpcom-legacy-redirector/health.svg)

```
[![Health](https://phpackages.com/badges/automattic-wpcom-legacy-redirector/health.svg)](https://phpackages.com/packages/automattic-wpcom-legacy-redirector)
```

###  Alternatives

[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/builder-plugin

Builder plugin for October CMS

17147.2k1](/packages/rainlab-builder-plugin)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5671.4k1](/packages/pfefferle-wordpress-activitypub)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

18238.1k2](/packages/civicrm-civicrm-drupal-8)[mediawiki/semantic-glossary

A terminology markup extension with a Semantic MediaWiki back-end

1352.4k](/packages/mediawiki-semantic-glossary)[humanmade/lottie-lite

A lightweight Lottie Animations Extension for WordPress

374.3k](/packages/humanmade-lottie-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
