---
title: "Rules Engine - Serpwise Documentation"
description: "Learn how rules define the SEO modifications the gateway applies to each request."
url: "https://serpwise.ai/docs/rules-overview/"
source: "https://serpwise.ai/docs/rules-overview/"
---
[Back to Serpwise](/)

Serpwise Documentation

Connect · Configure · Execute

Search documentation

`/`

No documentation found.

↑↓ Navigate Enter to open

Browse documentation

The **rules engine** is the heart of Serpwise. Rules tell the gateway what to look for in a request (conditions) and what to do when it finds a match (actions). Every SEO modification you make - setting meta tags, injecting structured data, modifying headers - is defined as a rule.

## What Is a Rule?

A rule has three parts:

1. **Name** - a label for your own reference
2. **Conditions** - criteria that must be true for the rule to fire (e.g. “URL path starts with `/blog/`”)
3. **Actions** - modifications to apply when conditions match (e.g. “set meta robots to `noindex`”)

When a request comes in, the gateway evaluates every enabled rule. For each rule where the conditions match, the actions are applied to the HTML response.

## Rule Priority

Rules are evaluated in **priority order** - lower numbers run first. When multiple rules match the same request, all of them are applied, but in priority order.

This matters when rules affect the same element. For example, if rule #1 sets the canonical to `/page-a/` and rule #2 sets it to `/page-b/`, the last one applied (rule #2) wins.

Use priority to control the order of operations deliberately. You can reorder rules by dragging them in the Rules tab.

## Enabling and Disabling Rules

Each rule has an enable/disable toggle. Disabled rules are skipped entirely during evaluation - they don’t count against performance and don’t affect responses.

Use this to:

- Temporarily disable a rule without deleting it
- Keep experimental rules off until you’re ready to activate them
- Quickly roll back a change by disabling the rule

## Rule Statistics

Each rule tracks:

- **Triggered count** - how many requests have matched this rule since it was created
- **Last triggered** - timestamp of the most recent match

Use this to identify rules that are never firing (possible condition misconfiguration) or rules that are firing unexpectedly often.

## URL Simulator

The **URL Simulator** in the Rules tab lets you test your rules without sending real traffic. Enter a URL and optionally specify:

- Request method
- Custom request headers
- User agent string

The simulator evaluates all your enabled rules against the simulated request and shows:

- Which rules match
- What actions would be applied
- The expected output HTML (where applicable)

## Common Use Cases

### Add `noindex` to staging or parameter pages

Apply `set_meta_robots` with a `noindex, nofollow` value to any URL matching a pattern:

```
Condition: url.path starts_with /staging/
Action:    set_meta_robots → "noindex, nofollow"
```

### Set canonical tags site-wide

Apply a canonical based on the current URL to prevent duplicate content issues:

```
Condition: response.status_code equals 200
Action:    set_canonical → https://www.example.com{url.path}
```

### Inject JSON-LD structured data on product pages

Target a specific URL pattern and inject schema markup:

```
Condition: url.path starts_with /products/
Action:    inject_json_ld → { "@type": "Product", ... }
```

### Block AI crawlers from specific content

Use bot detection conditions to target specific crawlers:

```
Condition: request.bot_name equals "GPTBot"
Action:    set_response_header → X-Robots-Tag: noindex
```

### Fix broken hreflang across localized pages

Add hreflang link elements without touching your CMS:

```
Condition: url.path starts_with /en/
Action:    add_hreflang → lang=en, href=https://www.example.com/en{url.path}
```

## Learn More

[**Conditions**  
→  
\
All condition types, operators, and how to combine them with AND/OR logic.](/docs/conditions)

[**Actions**  
→  
\
Every action available in the rules engine with examples.](/docs/actions)