Project rules let you control how Agiler handles HTTP traffic for a project. Use them to redirect a secondary domain, rewrite a request before it reaches WordPress, add response headers, or return a custom response without running WordPress.

Add or edit a rule

You need the Admin or Developer role in the project’s workspace to manage rules.

  1. In the dashboard, open the workspace and project. Select Rules in the project sidebar, then Add Rule.
  2. Choose a template or select Create a custom rule. Both open the rule editor. Replace any sample domains, paths, or IP addresses in a template before enabling it.
  3. Enter a Description that will help you identify the rule in the list. Set its Priority and choose Active or Inactive. New rules start active; switch to Inactive if you want to save the configuration for review.
  4. Under Conditions, choose how the conditions match. For each condition, select a Fact and an Operator, then enter or select a Value. Use the Name field if the fact asks for a header name.
  5. Under Actions, add at least one action. Choose set to change a request or response field, or end to stop evaluating further rules in that pass. For a set action, choose the Fact to change and enter its new Value.
  6. Click Create. Use the toggle in the rules list to enable or disable the rule. To change its configuration, select Edit rule, make your changes, then click Save. To remove it, select Delete rule and confirm.

How rules are evaluated

  • All requires every condition to match. Any requires at least one. None requires that no condition matches. Always matches every request and takes no conditions. A custom rule starts on Always; change it if your rule should apply only to specific traffic.
  • Lower Priority numbers run first within each pass. Use distinct priorities when two rules interact. A later rule can overwrite a header set by an earlier rule.
  • Agiler evaluates request conditions before forwarding to WordPress. Response-dependent conditions wait for a response. If you want to rewrite what WordPress receives, use request facts for both the conditions and the action values.
  • For a redirect or a custom response that should skip WordPress, match on request facts, set the response status and any headers or body, and put end last. Without end, processing continues. A rule that sets a response header without end can add that header to the response returned by WordPress.

New projects include Always use HTTPS at priority 0. It sends a 301 redirect for HTTP requests, preserving the path and query string. Because it ends the request, a rule with a higher priority number might only run after the browser follows the redirect to HTTPS.

A project can have up to 50 rules, including inactive rules. Priorities range from 0 to 99999.

Rule variables (facts)

Facts are values from the current HTTP request or response. Use the following facts in conditions:

Fact Value Comparisons
request.source.ip Client IP address Equality
request.method HTTP method, such as GET or POST Equality
request.protocol http or https Equality
request.host Hostname without the port Text
request.path Decoded URL path without the query string Text
request.uri Encoded path and query string, including the ? when there is a query Text
request.query Raw query string without the leading ? Text
request.header.<name> Value of a named request header Text
response.status HTTP status code, such as 404 Numeric
response.header.<name> Value of a named response header Text
  • Equality: equal, not_equal.
  • Text: equality plus contains, not_contains, starts_with, and ends_with. Text comparisons are case-insensitive. Regular expressions and wildcard matching aren’t supported.
  • Numeric: equality plus greater_than, less_than, greater_than_or_equal, and less_than_or_equal.

Reuse facts in values

In a free-text Value field, put a fact in braces to insert its current value. For example, https://example.com{request.uri} keeps the encoded path and query string when redirecting to another domain. For a header, use its full fact in braces, such as {request.header.Accept-Language}. An unknown placeholder stays as literal text.

Rules can’t read project environment variables or values marked Sensitive. Those variables configure your application.

Change request or response values

With set, you can change the request IP, method, scheme, host, path, query, or a named header. You can also set the response status or a named response header, or supply a body for a custom response. request.uri is read-only; set the path and query separately to rewrite them.

  • Headers: Choose request.header.* or response.header.*, then enter the actual header name under Name, such as Location. The * indicates where the name goes. Agiler reserves its own X-Agiler headers and prevents rules from rewriting certain connection headers.
  • Queries: Use request.query to replace the entire query string. Use request.query.* and enter a case-sensitive parameter name under Name to replace that parameter’s values while retaining the others. This re-encodes the query and can change the order of parameters. A named query parameter is an action target; match against request.query to inspect the raw query instead.
  • Bodies: response.body is an action target. You can’t match against it or insert it into another value.

Example: Redirect a secondary domain

  1. Make sure both hostnames are connected to the project and ready to serve HTTPS. In Rules → Add Rule, select Redirect to the primary domain.

  2. In Conditions, set the request.host value to the secondary hostname, such as www.example.com. Leave the operator as equal.

  3. In Actions, set response.header.* with Name Location to https://example.com{request.uri}, replacing example.com with the primary hostname. Keep the 301 status and the final end action. Match only the secondary hostname to avoid a redirect loop.

  4. Create and enable the rule. Test an HTTPS URL on the secondary domain and check the 301 status and Location header:

    curl -sS -D - -o /dev/null 'https://www.example.com/shop?sort=new'
    

    The Location should be https://example.com/shop?sort=new. Check that a request to the primary hostname is unaffected. If the result is wrong, disable the rule while you adjust it.

Troubleshoot and automate

  • If a rule doesn’t match, check that it’s active, test the exact scheme, hostname, and path, and look for an earlier rule that ends processing. If a header has an unexpected value, check whether another matching rule overwrites it.
  • Templates for WordPress and WooCommerce private pages set Cache-Control headers. Review the paths and run these rules after other cache-header rules. Configure exclusions separately for any edge or WordPress plugin caches. The Discourage indexing template sends indexing and cache headers but leaves the site accessible.
  • For automation, see the project rules API, the conditions and actions catalog, the CLI command reference, and the MCP tool reference.