How can WP Engine apply a response header rule to selected requests?

The Citead team, updated

In short. WP Engine applies a response header rule when every attached and-condition matches the request.

Definition: WP Engine's Web Rules Engine lets you create response-header rules in the User Portal and limit them with match conditions. An and-condition makes the rule take effect only when every condition attached to it is met.

Key facts

  • WP Engine describes Web Rules as a User Portal service for access, response-header, and rewrite rules. Its Web Rules Engine documentation places header rules in their own tab for each environment.
  • A response header carries additional information about a response, such as its location or the server providing it, according to MDN's HTTP headers reference.
  • WP Engine's header rules can set or unset a header by name, and the rules are read in cascading order.
  • An and-condition combines tests with the boolean and operator, so every attached condition must be met before the rule takes effect.
  • The available comparison operators are Equal to, Not equal to, Regex matches, and Negative regex matches.

How do header rules select requests?

Open an environment in the WP Engine User Portal, select Web Rules from the secondary menu, open Header Rules, and click Add rule. The documentation says that Web Rules functionality is enabled by default on all environments, although it can be disabled while troubleshooting.

The rule has a header action and one or more conditions. A condition has a type, an operator, and a value. WP Engine lists URI, query argument, request method, request header, GeoIP country code, and IP as condition types. A request can therefore be narrowed by its path, query data, method, request metadata, country, or address.

For a host-specific rule, WP Engine gives this condition:

Type: Header
Name: HOST
Operator: Equal to (=)
Value: example.com

The same documentation says that a query-argument value is entered without the leading question mark. Its example uses color=red to match a query string parameter. For pattern matching, choose a regex operator and enter the pattern in the Value field.

How do you set a response header for a path?

In the Header Rules tab, choose Set, enter the response-header name and value, choose when the header applies, and add the URI condition. WP Engine's example sets Cache-Control on successful responses for requests whose URI matches /resources/:

Action: Set
Name: Cache-Control
Value: max-age=604800, public
When: Only on successes
Conditions:
  Type: URI
  Operator: Regex matches (~)
  Value: /resources/

MDN defines Cache-Control as a header whose directives control caching in browsers and shared caches. Its reference states that multiple directives are comma-separated and that max-age=N keeps a response fresh for N seconds after it is generated. The value in WP Engine's example therefore contains a cache lifetime and the public response directive, while the rule's path condition limits where that header is applied.

WP Engine also documents an Unset action. Its example removes Set-Cookie from all responses, while another example sets Access-Control-Allow-Origin to * only on successful responses. Header rules can be used for security headers, cache-control headers, and other response-header changes supported by the interface.

How do order and restrictions affect the result?

WP Engine says header rules are read in cascading order, so place a more specific rule where its position gives it the intended priority. The list can be rearranged with drag and drop, and a new rule can be inserted above or below an existing rule. The service also lets you add comments to rules to document order-sensitive exceptions.

Some names are restricted. WP Engine lists server, date, x-powered-by, x-cache, x-cacheable, and any header that includes WPE among the headers restricted from Web Rule functionality. The documentation attributes these restrictions to conflicts with platform features or unsupported headers.

FAQ

Can one header rule require several request properties?

Yes. Add several and-conditions to the rule. WP Engine defines these conditions as a boolean and, so the rule takes effect only when all attached tests are met.

Can a rule match a query parameter?

Yes. Choose Query string as the condition type, then use an exact or regex operator. WP Engine's example enters color=red without a leading ?.

Can a header rule remove a response header?

Yes. Choose the Unset action and enter the header name. WP Engine documents Set-Cookie as an example that can be unset for all responses.

Where is the rule configured?

Select the environment in the User Portal, open Web Rules, choose Header Rules, and click Add rule.

Sources

  1. WP Engine, "Web Rules Engine", 2 March 2026
  2. MDN Web Docs, "HTTP headers", 17 September 2026
  3. MDN Web Docs, "Cache-Control header", 17 September 2026

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