Which WP Engine rewrite rule runs when several rules match a URL?

The Citead team, updated

In short. The first matching WP Engine rewrite rule takes priority, so specific rules should appear above broad patterns.

Definition: WP Engine evaluates Web Rules from top to bottom. When several rewrite rules can apply to a request, the first rule whose conditions are met is triggered, so a specific rule belongs above a broader pattern.

Key facts

  • WP Engine's Web Rules Engine documentation says Web Rules are read from top to bottom and rules read first take priority.
  • The same documentation says the first rewrite rule whose conditions are met is triggered, while the rule source acts as an implicit URI condition.
  • WP Engine's RegEx documentation defines a regular expression as a search pattern that can match multiple URLs dynamically.
  • The Apache mod_rewrite reference also states that the order of rewrite rules determines their runtime order.

Which rule wins when two rewrite rules match?

WP Engine documents a cascading order for rewrite rules. The first rule whose conditions are met takes effect. If a URL is affected by multiple rewrite rules, the topmost rule takes priority over the other applicable rules. A broad source pattern placed above a narrower pattern can therefore handle a request before the narrower rule is reached.

The source field is part of that test. WP Engine describes the source as a regular expression that must match the original request URI, including the query string, for the rewrite to happen. Conditions can further limit when the rule triggers. A rule with a specific source and conditions should be placed above a rule with a more general source when both can match the same request.

What does a rewrite rule change?

The Web Rules Engine adds rewrite rules to Nginx. WP Engine describes a rewrite as a way to change the URL requested by a client and route the client to a new location. Its internal rewrite action returns content from the destination without redirecting the client to another URI.

The documentation gives this internal rewrite example:

Request URI: /page-1
Action: Internal rewrite
Destination: /page-2

The public request can remain /page-1 while the content from /page-2 is returned. A redirect action has a different client-visible result because it sends the request to the location defined in the destination.

How should specific rules be placed above general patterns?

The Web Rules page includes a drag-and-drop control for rearranging rules. It also describes adding a new rule in relation to an existing rule as useful when order is significant, and recommends the relative adding method when possible. This keeps the specific rule ahead of a broad pattern at the point where the new rule is created.

Regular expressions make the distinction between specific and broad sources. WP Engine says its rules are case-sensitive and that case-insensitive RegEx may be necessary. The same page explains that a dollar sign at the end of a source and a trailing slash at the end of a destination can help avoid redirect loops.

FAQ

Which rule should you move first?

Move the rule with the narrower source or conditions above the broader rule. WP Engine states that the first rewrite rule whose conditions are met is triggered.

Can you change the order after creating a rule?

Yes. You can rearrange rules with the documented drag-and-drop control, or add a new rule in relation to an existing rule when order matters.

Does the source pattern include the query string?

Yes. WP Engine documents that the source regular expression must match the original request URI, including the query string, for the rewrite to happen.

Sources

  1. WP Engine, "Configure Web Rules Engine", updated 2 March 2026
  2. WP Engine, "Configure RegEx for Redirects and SSL", updated 21 August 2025
  3. Apache Software Foundation, "mod_rewrite", publication date not stated

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark