Back to Community

How to Fix 'Too Many Redirects' Errors in Redirection for WordPress

32 threads Sep 16, 2025 PluginRedirection

Content

One of the most common and frustrating issues users encounter with the Redirection plugin is the dreaded "too many redirects" error. This problem typically occurs when a redirect rule you've created inadvertently creates an infinite loop, causing your browser to get stuck. Let's break down why this happens and how to fix it.

Why Do Infinite Redirect Loops Happen?

An infinite redirect loop occurs when a rule you create matches not only the URLs you want to redirect but also the URL you are redirecting to. The most common scenario is when trying to redirect all pages on a site to the homepage.

For example, a user might create a rule with the source URL ^/(.*) and the target URL /. The expression .* matches zero or more of any character. This means it will match the homepage (/) itself, causing the following chain of events:

  1. A visitor requests the homepage: yoursite.com/
  2. The rule matches because the path / contains zero characters after the slash.
  3. The plugin redirects the request to the target: yoursite.com/ (the homepage again).
  4. The rule matches again, and the process repeats infinitely, resulting in the error.

How to Fix the Redirect Loop

The solution is to refine your regular expression so that it does not match the target URL. You need to ensure the rule only applies to pages that are not the homepage.

Solution 1: Use the + Quantifier Instead of *

A simple and effective fix is to change the quantifier in your expression. Use + (which matches one or more characters) instead of * (which matches zero or more).

  • Old Rule (Causes Loop):
    Source: ^/(.*)
    Target: /
  • New Rule (Works Correctly):
    Source: ^/(.+)
    Target: /

The new expression ^/(.+) will match any URL path that has at least one character after the slash (e.g., /about, /old-page). It will not match the homepage (/) because there is not "one or more" characters after the slash, thus preventing the loop.

Solution 2: Explicitly Exclude the Target URL

For more complex scenarios, you can write an expression that explicitly excludes your target URL or a specific pattern. This requires a more advanced understanding of regular expressions.

For instance, if you want to redirect all URLs except a specific maintenance page, your expression must avoid matching that page's path.

Best Practices and Testing

  • Test Your Expressions: Before saving a new rule, always test your regular expression on a site like Regex101.com. Check that it matches the URLs you want and, crucially, does not match your target URL.
  • Check the Order: If you have multiple redirects, remember that rules are processed from top to bottom. More specific rules should have a lower position number (appear higher in the list) than general catch-all rules.
  • Read the Documentation: The Redirection team provides extensive documentation on using regular expressions, complete with examples and links to helpful guides.

By carefully crafting your redirect rules to avoid matching the destination, you can effectively use Redirection to manage your site's URLs without triggering errors.

Related Support Threads Support