Back to Community

How to Fix Redirection Issues with Regular Expressions and Wildcards

39 threads Sep 16, 2025 PluginRedirection

Content

If you're using the Redirection plugin and finding that your redirects aren't working as expected—perhaps they're appending extra parts of the URL or not capturing the patterns you need—you're not alone. This is a common hurdle, especially when moving sites or changing URL structures. This guide will walk you through the most frequent causes and their solutions.

The Core Problem: Understanding Regular Expressions

The most prevalent issue, as seen in numerous support threads, is a misunderstanding of how to use regular expressions (regex) for wildcard matching. A standard redirect without regex will perform a simple, literal match. To capture dynamic parts of a URL (like a changing post slug), you must use regex.

Common Scenario 1: Redirecting an Entire Directory

Problem: You want to redirect all URLs under an old directory (e.g., /trends/) to a single new page (e.g., /events/), but the redirect is incorrectly appending the old page slug to the new URL, sending users to a 404 page.

Incorrect Setup:
Source: /trends(.*)
Target: /events

Solution:
You must use a regex capture group and then ignore it in the target. Enable the "Regex" checkbox and use this structure:
Source: /trends/(.*)
Target: /events/
Note the trailing slash in the target. The (.*) captures any text after /trends/, but since you don't reference it (e.g., with $1) in the target, it is discarded.

Common Scenario 2: Changing URL Structures (e.g., Removing Categories)

Problem: You've changed your permalink structure to remove a category base (e.g., changing from /category/post-name/ to /post-name/) and need to redirect all old URLs.

Solution:
This is an ideal use case for the "Permalink Migration" feature built into Redirection.

  1. Go to Redirection > Options > Site.
  2. In the "Permalink Migration" section, enter your old permalink structure. For example, to remove /category, you might enter /category/%postname%.
  3. Save the changes. The plugin will now automatically handle redirects from the old structure to the new one without manually creating hundreds of rules.

Common Scenario 3: Redirects Not Firing for External Domains or Subdomains

Problem: You are trying to redirect a URL from an entirely different domain (e.g., blog.old.com) or a subdomain to your main WordPress site, but the plugin's source field only accepts relative paths.

Solution:
The Redirection plugin primarily manages redirects for its installed domain. To redirect from a different domain, you typically need to implement the redirect on the server hosting that original domain. For subdomains of the same domain, you can sometimes use the "URL and Server" match type. In the redirect rule, set the "Source" to the path and the "Match" type to "URL and Server." Then, you can specify the subdomain in the server field.

Why Your Redirect Might Still Not Work

If you've configured your regex correctly but the redirect isn't triggering, consider these other factors:

  • Caching: A stubborn page or browser cache might be serving the old, broken page. Clear your site's cache and your browser cache before testing again.
  • Conflicting Rules: A more specific redirect rule might be taking precedence over your new, broader rule. Review your list of redirects for any conflicts.
  • Server Configuration: For redirecting files outside of the WordPress installation (like PDFs in an old server directory), server-level restrictions or other software (like security plugins on the server) can sometimes interfere. The Redirection plugin requires that the request is first processed by WordPress for it to act.

By methodically checking your regular expressions and understanding the scope of what the plugin can handle, you can resolve most redirection issues and ensure a smooth experience for your visitors and SEO.

Related Support Threads Support