Must-Have Redirect Documentation

Current Version: 0.2.0
Text Domain: mhredirect

Must‑Have Redirect detects 404 requests, then either applies your manual rules or finds the most relevant content using similarity matching. It prevents loops, records rule hits, and can serve a custom 404 page when no good target exists.

How it works

Request flow

  • Normalize path: Trailing slashes removed; tracking params filtered; remaining query sorted.
  • Rules: On a 404 request, exact rules are checked first, then wildcard and regex rules. Rules marked Apply even if the page exists are checked on every request.
  • Skip and 410 rules: A skip rule stops every redirect for the URL; a 410 rule answers with 410 Gone.
  • Smart 404: If enabled and no rule matched, find similar content by Levenshtein threshold (Close Match / Likely Relevant / Fallback). Bots and file requests are skipped.
  • Safety: Prevent self‑redirects; auto rules created for smart matches; status 302 for auto.
  • Custom 404: If nothing matched (or a skip/410 rule matched), optionally render a selected WordPress page.
  • Hit counters: Every rule shows its total hits and the date of the last hit.

Getting Started

Choose the right plan

Must-Have Redirect is an intelligent 404 handling and URL redirection plugin. There are 2 available plans:

Single plan

You can use Must-Have Redirect with Single plan for 1 WordPress site. It can be the right choice if you have only 1 site, or if you would like to test what Must-Have Redirect can do (you can upgrade your subscription later).

Multi plan

You can use Must-Have Redirect with Multi plan for up to 5 WordPress sites. If you have at least 2 sites, Multi plan is the better choice.

More than 5 sites

For unlimited sites choose the Must-Have Pack: every Must-Have plugin, including Must-Have Redirect, on unlimited websites with one subscription.

The Unlimited plan was retired on July 22, 2026. Existing subscriptions on this plan keep working and renewing as before.


Install Must-Have Redirect

  1. Login to My account on musthaveplugins.com
  2. On the next screen you will see all available plugins. Download Must-Have Redirect installer from the Must-Have Redirect box
  3. Login to WordPress admin where you would like to install Must-Have Redirect
  4. Go to Plugins > Add new and click to upload plugin
  5. Select the previously downloaded ZIP file (must-have-redirect.zip) and click to install
  6. Activate the plugin and open Tools > Must-Have Redirect. If Rank Math, Yoast SEO, All in One SEO, The SEO Framework or SEOPress is active, you find it in that plugin's menu as Smart Redirects instead. The page has four tabs: Settings, Redirects, 404 Log and Tools.

Configuration

Configure the basic functionality of the plugin in this section.

Smart 404 Handling

When enabled, the plugin automatically tries to find and redirect to the most relevant content when a 404 error occurs. This feature uses intelligent similarity matching to find the best possible destination.

Similarity Threshold

Choose how strict the plugin should be when matching similar content:

  • Close Match (10% difference): Only redirects to very similar URLs, best for catching minor typos
  • Likely Relevant (25% difference): Balanced approach, catches moderate URL variations
  • Fallback (50% difference): Most lenient, tries to avoid 404s by finding any potentially relevant content

Redirect on permalink change

When the slug or permalink of a published post or page changes, the plugin creates a permanent (301) redirect from the old URL to the new one. These rules are labelled Permalink change on the Redirects tab. Enabled by default. (Since 0.2.0)

404 Log

When enabled (default), the plugin logs 404 errors with the URL, the referrer, the result and the number of hits. Open the 404 Log tab to review them: click Redirect to create a redirect rule for a URL, or Skip to make sure it is never redirected. Bots and direct file requests are not logged, and entries older than 30 days are removed automatically. (Since 0.2.0)

Custom 404 Page

Select any WordPress page to serve as your custom 404 page. This page will be displayed when:

  • No matching redirect rule is found
  • No similar content is found
  • The found destination would create a redirect loop
  • A skip rule or a 410 rule matched the URL

Redirect Rules

Manage your redirect rules and view automatically generated redirects.

Manual Redirects

Open the Redirects tab and click Add New Rule. Each rule has these options:

  • Rule type: Redirect, or Skip (never redirect). A skip rule means the matching URLs are never redirected: not by redirect rules, smart 404 or WordPress core guesses. The visitor sees the 404 page.
  • Match: Exact / wildcard (*) or Regular expression.
  • Pattern: The URL path to match, for example old-page or blog/*. Each pattern must be unique.
  • Status: 301 Permanent (default), 302 Temporary, 307 Temporary (Strict), 308 Permanent (Strict), or 410 Gone. A 410 rule needs no destination: it tells search engines that the page was removed for good.
  • Destination: Where to redirect matching URLs, for example /new-page/ or https://example.com/.

Smart 404 matches create auto rules with status 302. Click Keep next to an auto rule to turn it into a permanent 301 redirect that is never removed automatically.

Advanced options

By default a rule is applied only when the requested URL doesn't exist (404). Open Advanced in the rule editor for more control:

  • Apply even if the page exists (not only on 404): The rule redirects existing pages too.
  • Visitor: Anyone, Logged in users or Logged out visitors.
  • Device: Any device, Mobile or Desktop.
  • Browser language: Comma-separated language codes, for example hu, de-at. The rule applies when the visitor's preferred browser language matches.

Note: Conditional rules send no-cache headers, but a full page cache may still serve a cached version. (Since 0.2.0)

Wildcard and Regex Patterns

Use * as a wildcard in your patterns. The part matched by each * can be used in the destination as $1, $2… Examples:

  • old-product/* → Matches all URLs starting with "old-product/"
  • *.html → Matches all URLs ending with ".html"
  • blog/* with destination /news/$1 → /blog/hello is redirected to /news/hello

With the Regular expression match type, the expression is matched case-insensitively against the path without the leading slash, for example ^blog/(\d+)/(.*)$ → /news/$2. (Since 0.2.0)


Tools

  • Test URL: Enter a URL to see which rule would be applied, or where smart 404 would redirect it.
  • Export: Download your redirect and skip rules as a CSV file. Auto rules created by smart 404 are not exported.
  • Import CSV: Columns: pattern, destination, status (optional: type, match_type, always, conditions). A header row is optional. Rules with an existing pattern are skipped.
  • Import from other plugins: Copy existing redirects from Redirection, Rank Math or Yoast SEO Premium. Imported rules are applied even if the page exists, like in the original plugin. Rules with an existing pattern are skipped.

(Since 0.2.0)


URL Handling

Learn how the plugin processes and normalizes URLs.

URL Normalization

The plugin automatically normalizes URLs for consistent matching:

  • Removes trailing slashes
  • Removes tracking parameters (utm_*, fbclid, etc.)
  • Sorts remaining query parameters alphabetically

Ignored Query Parameters

These query parameters are automatically removed by default:

  • utm_source, utm_campaign, utm_medium, utm_expid, utm_term, utm_content
  • fb_action_ids, fb_action_types, fb_source, fbclid
  • _ga, _gl, gclid
  • age-verified, rdt_cid, li_fat_id

Loop prevention

Redirects are skipped if the destination path equals the current normalized path to avoid loops. Smart 404 redirects and manual rules both observe this safety.


Bot Protection

Smart 404 matching and the 404 log skip the following requests, so they don't create auto rules or log entries:

  • Empty or suspicious user agents (eg. curl, wget, python-requests, libwww-perl, java, scrapy, okhttp, go-http, jakarta, aiohttp)
  • Malicious URL patterns and direct file access attempts (eg. wp-admin, wp-json, cgi-bin, shell, passwd)
  • Direct requests to common file types (eg. .php, .sql, .gz, .zip, images, fonts, audio/video, css, js, xml, pdf, txt)

Your own redirect, skip and 410 rules still apply to these requests, so you can redirect an old file URL such as /brochure.pdf too. Smart 404 runs only for GET and HEAD requests.

Maintenance

A scheduled task runs daily and removes 404 log entries older than 30 days. On Sundays it also removes auto rules that were not used in the current week or have fewer than 10 hits this week. Rules you kept are not affected.

Database schema

Redirect rules are stored in wp_mhredirect_rules with fields: id, type (redirect/skip), match_type (exact/wildcard/regex), pattern, destination, status, always, conditions (JSON), hits and woy (this week's hits and week-of-year), total_hits, last_hit, auto (0/1), source (manual/auto/slug/import), created. The 404 log is stored in wp_mhredirect_404_log.


Best Practices

  • Start with "Close Match" similarity and adjust based on your needs
  • Review auto-generated redirects periodically
  • Use wildcards carefully to avoid unintended matches
  • Monitor hit counters to identify frequently used redirects
  • Consider creating permanent (301) redirects for commonly used patterns

Available Filters

Customize the plugin's behavior using these filters:

mhredirect/current_path

Modify the normalized path (after param filtering and sorting) before redirect processing.

// Modify the normalized path
add_filter('mhredirect/current_path', function($path) {
      // Your modifications here
      return $path;
});

mhredirect/remove_query_params

Customize which query parameters are removed during normalization.

// Customize which query parameters to remove
add_filter('mhredirect/remove_query_params', function($params) {
      $params[] = 'my_tracking_param';
      return $params;
});
                        

mhredirect/similarity_threshold

Adjust dynamic Levenshtein threshold per comparison. Arguments: $threshold, $word1, $word2.

add_filter('mhredirect/similarity_threshold', function($threshold, $w1, $w2) {
  // e.g. make brand words stricter
  if ($w1 === 'brand' || $w2 === 'brand') return max(1, $threshold - 1);
  return $threshold;
}, 10, 3);

mhredirect/option/{key}

Filter a specific option on read. See also mhredirect/option/not_set/{key} and mhredirect/update_option/{key}.

mhredirect/print_template/{template}

Override the admin template path before include. Used to integrate with SEO suites.

mhredirect/api_request_args

Filter arguments for remote API requests (headers, body, timeout, etc.) before calling the Must‑Have Plugins API.

mhredirect/similar_content

Change or cancel the target found by smart 404. Arguments: $result (array with id, score, url), $path. Return null to skip the redirect.

mhredirect/log/keep_days, mhredirect/log/max_rows

How long 404 log entries are kept (default 30 days) and the maximum number of entries (default 5000).

mhredirect/menu_parent, mhredirect/menu_position, mhredirect/menu_title, mhredirect/print_template/admin-header

Filters that place Must‑Have Redirect under SEO plugins (Rank Math, Yoast, AIOSEO, TSF, SEOPress).


Available Actions

mhredirect/option/{key}/updated

Fires when a specific option is updated. Parameter: new value.

mhredirect/option/updated

Fires on any option update. Parameters: $key, $value.

mhredirect/enqueue_assets

Allows integrations to enqueue admin styles/scripts and tweak admin body classes.

mhredirect_daily_cleanup

Scheduled action triggered daily; it prunes the 404 log, and on Sundays it also purges stale auto rules (not used this week or fewer than 10 hits this week).


Changelog

0.2.0 – 2026.09.27.
[NEW] Skip rules: never redirect selected URLs
[NEW] 404 log with referrer and hits
[NEW] Create rules from the 404 log with one click
[NEW] Automatic 301 redirect on permalink change
[NEW] Option to apply rules on existing pages too
[NEW] Regex rules and $1 captures in destination
[NEW] 410 Gone status
[NEW] Conditions: login state, device, language
[NEW] Hit counter and last hit date
[NEW] Keep auto rules as permanent 301 redirects
[NEW] URL tester
[NEW] CSV import and export
[NEW] Import from Redirection, Rank Math, Yoast
[FIX] Adding and editing rules failed
[FIX] Similarity threshold setting was ignored
[FIX] Search, sorting and pagination of rules
[FIX] Some manual rules were ignored
[FIX] Pages were never suggested by smart 404
[FIX] Keep the exact old slug redirect of WordPress
[FIX] Wildcards, query strings and non-ASCII URLs
[FIX] Uninstall left the rules table behind
[FIX] Security hardening for update checks
[IMPROVEMENT] Faster smart 404 on large sites

0.1.3 – 2025.11.24.
[FIX] Minor bugfixes

0.1.2 – 2025.04.15.
[FIX] Prevent redirects to non-public post types

0.1.1 – 2025.03.25.
[FIX] Minor bugfixes

0.1 – 2025.03.01.
Initial public beta release

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only