RTFM

Smart Redirect Manager

Smart Redirect Manager
Current Version
1.0.0
Requires WordPress
6.5
Tested Up To
7.0
Translations included
πŸ‡ΊπŸ‡Έ English
πŸ‡ͺπŸ‡Έ Spanish
πŸ‡«πŸ‡· French
πŸ‡©πŸ‡ͺ German
πŸ‡¨πŸ‡³ Chinese
πŸ‡―πŸ‡΅ Japanese

Overview

Smart Redirect Manager lets you build conditional redirects from the WordPress admin without writing code. It is designed for marketing, membership, and campaign routing workflows where the destination depends on who the visitor is, what device they use, where they came from, or what campaign data is present.

Requirements

  • WordPress 6.5 or newer.
  • PHP 7.4 or newer.
  • Administrator access to create and manage redirect rules.

Getting Started

  1. Activate Smart Redirect Manager.
  2. Go to Settings > Smart Redirects.
  3. Confirm Enable redirect engine is turned on.
  4. Add a redirect rule.
  5. Save the rules.
  6. Test with the Redirect Simulator and then in a private browser session.

The plugin only runs redirects on public GET and HEAD requests. It skips admin requests, AJAX, REST requests, cron, feeds, login/register pages, previews, and Customizer previews.

The admin screen is organized into tabs for Redirect Rules, Redirect Simulator, and Audit Log. Redirect rules use an accordion layout so the enabled state, name, priority, source, destination, status code, and condition count stay visible while the detailed rule settings remain collapsed until opened.

Rule Basics

Each rule has:

  • Enabled: Turns the rule on or off.
  • Rule name: A human-readable label for the admin screen and audit log.
  • Priority: Lower numbers run earlier.
  • Source URL: The URL or path to match.
  • Match type: Exact, contains, wildcard, or regex.
  • Status code: 301, 302, 307, or 308.
  • Condition logic: Require all conditions or any condition.
  • Destinations: One or more target URLs.
  • Preserve query string: Adds incoming query parameters to the destination.
  • Stop after this rule matches: Stops later rules from overriding the matched redirect.

Use paths like /pricing for same-site sources, or full URLs like https://example.com/pricing.

Source Match Types

  • Exact: The source must match exactly, ignoring trailing slash differences.
  • Contains: The source only needs to contain the entered text.
  • Wildcard: Use * to match flexible parts, such as /campaign/*.
  • Regex: Enter a regular expression for advanced patterns.

Conditions

Conditions let one source URL send different visitors to different places.

Supported condition fields:

  • User Role: Choose one or more available WordPress roles. Guests are represented as guest.
  • Logged In: Choose a yes/no login state.
  • Device Type: Choose desktop, mobile, or tablet. List operators allow selecting multiple devices.
  • Time of Day: Choose a preset such as Business hours or set custom start/end times. Overnight ranges like 22:00-06:00 are supported.
  • Country: Choose one or more country codes from the country selector.
  • Referrer: Match the incoming referrer URL.
  • UTM Parameter: Put the parameter name in the Parameter field, such as utm_source, and the expected value in Value.
  • Cookie: Put the cookie name in the Parameter field and the expected value in Value.

The condition editor changes its controls based on the selected condition type. Role and country conditions show multi-select lists, login status shows a yes/no selector, device type shows device options, and time-of-day conditions show presets plus start/end time fields.

Supported operators:

  • Equals
  • Does Not Equal
  • Contains
  • Does Not Contain
  • Exists
  • Does Not Exist
  • In List
  • Not In List
  • Between Times

For list operators, separate values with commas, such as US,CA,GB.

Geolocation

Smart Redirect Manager reads common CDN and server geolocation headers:

  • CF-IPCountry
  • CloudFront-Viewer-Country
  • X-Country-Code
  • GEOIP_COUNTRY_CODE

The plugin does not send visitor IP addresses to an external geolocation service. If your host or CDN does not provide a country header, country conditions will not match unless a developer supplies country data with the wwpsrm_request_context filter.

Weighted Destination Splits

One rule can have multiple destinations. Each destination has a weight. For example:

  • Landing Page A: weight 70
  • Landing Page B: weight 30

New visitors are assigned by weighted random selection. The plugin stores a secure, HTTP-only bucket cookie for 30 days so the same visitor keeps seeing the same destination for that rule.

Redirect Simulator

The Redirect Simulator lets you test rules before live traffic hits them. Enter:

  • Request URL
  • Role
  • Device
  • Time
  • Country
  • Referrer
  • UTM values
  • Cookies

The simulator reports whether a rule matched and which destination/status code would be used.

Analytics and Audit Log

The plugin tracks:

  • Total hits per rule.
  • Last matched time per rule.
  • Recent redirect log entries.

The audit log is capped by the Maximum log rows setting and is stored in WordPress options. No custom database table is created.

Security Notes

  • Only users with manage_options can edit rules.
  • All admin saves use nonces.
  • Source, destination, condition, and setting fields are sanitized before storage.
  • Redirects are skipped for non-public request types.
  • External redirect hosts are only allowed during the specific safe redirect call.
  • Administrators are bypassed by default.

When Bypass administrators is enabled, role-based redirects will not run for your current administrator session. This is intentional lockout protection. To test a rule that targets the Administrator role, temporarily disable the bypass setting or test with a separate non-admin account for another selected role.

Uninstalling

Deleting the plugin removes:

  • Redirect rules
  • Engine settings
  • Redirect stats
  • Redirect audit logs
  • The plugin updater transient

Developers

Smart Redirect Manager includes filters and actions for extending request context, rules, conditions, destinations, and logging.

wwpsrm_request_context

Use this filter to add or override visitor context before rules are evaluated.

add_filter( 'wwpsrm_request_context', function( $context ) {
    $context['country'] = 'US';
    return $context;
} );

wwpsrm_rules

Use this filter to modify the rule list at runtime.

add_filter( 'wwpsrm_rules', function( $rules, $context ) {
    if ( ! empty( $context['query']['preview_redirects'] ) ) {
        return array();
    }

    return $rules;
}, 10, 2 );

wwpsrm_condition_result

Use this filter to override a condition result.

add_filter( 'wwpsrm_condition_result', function( $result, $condition, $context, $rule ) {
    if ( 'cookie' === $condition['field'] && 'vip' === $condition['param'] ) {
        return ! empty( $context['cookies']['vip'] );
    }

    return $result;
}, 10, 4 );

wwpsrm_redirect_destination

Use this filter to alter the final destination URL before redirecting.

add_filter( 'wwpsrm_redirect_destination', function( $destination, $rule, $context, $match ) {
    return add_query_arg( 'redirect_rule', rawurlencode( $rule['id'] ), $destination );
}, 10, 4 );

wwpsrm_before_redirect

Use this action to run code immediately before the redirect response is sent.

add_action( 'wwpsrm_before_redirect', function( $rule, $context, $destination, $match ) {
    error_log( sprintf( 'Smart Redirect Manager matched %s to %s', $rule['name'], $destination ) );
}, 10, 4 );

wwpsrm_log_entry

Use this filter to add fields to the audit log or skip logging for selected redirects.

add_filter( 'wwpsrm_log_entry', function( $entry, $rule, $context, $match ) {
    $entry['campaign'] = isset( $context['query']['utm_campaign'] ) ? $context['query']['utm_campaign'] : '';
    return $entry;
}, 10, 4 );

Changelog

1.0.0 – 2026-04-16

  • Add visual redirect rules with source matching, priorities, status codes, and AND/OR condition logic.
  • Add tabbed admin sections for redirect rules, simulator, and audit log.
  • Add accordion rule editing so rule headers stay compact until opened.
  • Add collapsed rule summaries for source, destination, status code, and condition count.
  • Add an admin bypass warning for User Role conditions so role tests are easier to diagnose.
  • Add adaptive condition controls for roles, login state, devices, countries, and time ranges.
  • Add user role, login status, device, time, country, referrer, UTM, and cookie conditions.
  • Add weighted destination splits with sticky visitor bucketing.
  • Add redirect simulator for testing visitor scenarios before live traffic changes.
  • Add analytics counters and a capped audit log for recent redirects.
  • Add uninstall cleanup, internationalization support, compatibility guards, and admin security checks.