Priority
When more than one redirect rule matches a request, AlterURL needs a way to pick a single winner. Priority is part of that, but it isn't the first thing that's checked.
How It Works
AlterURL evaluates every rule against the incoming request. Among the rules that match, the winner is chosen in two steps:
- Most specific match wins first. The matched rule(s) with the highest number of conditions satisfied are kept; any matched rule with fewer conditions is dropped, regardless of its priority.
- Priority breaks ties. If more than one rule is still tied after step 1 (i.e. they matched the same number of conditions), the one with the highest priority value wins. Priority is an optional number on each rule — higher means higher priority, and an unset priority is treated as
0.
In short: a rule with more matching conditions always beats a rule with fewer, even if the fewer-condition rule has a higher priority. Priority only decides between rules that are equally specific.
Example
You have two rules:
- Rule A — matches "device is mobile" (1 condition) — Priority: 100
- Rule B — matches "device is mobile" AND "custom attribute
campaignisblack-friday" (2 conditions) — Priority: 10
A mobile user visiting the link with ?campaign=black-friday matches both rules. Rule B matches more conditions (2 vs 1), so Rule B wins, even though Rule A has the higher priority.
Now compare two equally specific rules:
- Rule C — matches "device is mobile" (1 condition) — Priority: 10
- Rule D — matches "country is US" (1 condition) — Priority: 100
A mobile user from the US matches both, and both match exactly 1 condition each — so this time it's a tie after step 1, and Rule D wins on priority.
Best Practices
- Add conditions to make campaign or time-sensitive rules more specific, rather than relying on priority alone — a more specific rule always wins over a less specific one.
- Use priority to break ties between rules you expect to be equally specific (e.g., several single-condition rules for different device types or countries).
- Use low priority (e.g., 10) for broad fallback/default rules with few conditions, since any more specific rule will already take precedence over them.